n 02/10/2013, Raman Gopalan <
ramang...@gmail.com> wrote:
>> I see Raman has been busy again, adding tinyscheme, so now Lua,
>> PicoC, PicoLisp, MyBASIC and tiny scheme all run on the Mizar32.
>> That leaves one language for the magic 6.
>
> There are many interesting languages/virtual machines that can run on
> Mizar32. I hope we don't stay at 6. List: Just a thought - Can we change
> the significance of 6 to paradigms instead of languages? :)
Of course, but see below for a possible workflow to avoid eternal
development never released...
>> I'd like a Forth, for its
> If you have a specific preference/implementation, please
> give me your suggestion
I have no preferences, and I think you are the best judge of the
suitability of different implementations.
>> An alternative is a pure functional language, but Hugs, the standard
>> Haskell interpreter, is too big, leaving it predecessors, KRC and
>> Miranda, whose interpreter source code I am seeking.
>
> Ocaml, Erlang - interesting. I was able to compile Hugs for Mizar32
> (SMALL_HUGS mode with changes in the code base). It reaches a
> point where it loads Prelude.hs from /mmc and crashes. I'm debugging
> this. But as Martin said it is very big. It takes away 88% - 90% of
> flash on Mizar32 A
Excellent news, I didn't think it would fit at all, having seen that
the x86 binary is 785K of compiled code, without counting the
libraries that it uses. Well done!
>> Binaries of the first four languages in various flavours are visibile
> under
>>
http://simplemachines.it/downloads/Alcor6L<
http://simplemachines.it/downloads/Alcor6L>
> Martin: Thank you very much for putting the binaries up.
Not at all the "release" I promised you! That turned out to be too
much work, so for the moment I can put up a monthly compile of the
binaries.
>> @Raman, can we rename the binaries like this in the builder, with
>> build date included?
> Certainly Martin. I'll include this in SConstruct.
Thanks. That makes release management abd version tracking much easier.
On a different topic, there is an interesting problem to solve with
pure functional languages.
All of Alcor6L's current languages, including the functional ones,
handle the devices by supplying functions which, when you call them,
either have some side-effect on an I/O device as a side effect of what
they do, or their return value depends on the current state of some
input pin or I/O device.
In pure functional languages, a function cannot have side effects:
its return value depends ONLY on the function's code and the
parameters supplied at runtime, and cannot be different depending on
the voltage on some input pin.
Similarly, the only thing a pure function does is return a result:
it cannot have the additional effect of twiddling an output pin.
These concepts are essential to pure functional languages: if you call
the same function twice with the same parameters, it is free to
execute once and return you the same result twice. In fact, the
functions are not "evaluted" as in other languages: they are rewritten
at runtime, so add(2, 3) is rewritten as 5 the first time it is
called. As a concrete example, delay(1 second) might delay for a
second and say "yes, that worked" the first time you call it, but any
further calls would immediately return "yes, that worked" as the
function call would have been replaced by its result.
In a pure functional language, you have to work by saying: "the main
function's parameter is all the program's input, and its return value
is all program's output".
For a visual editor, for example, the input is the original file and
the keystrokes the user types, and the output is the sequence of
screen updating characters and the modified version of the file. While
the editor is running, it is driven by the need to produce output, and
that output depends on what the user types. If they type the
"delete-line" command, that input gives the main function the info it
needs to be able to generate some more output: the screen-updating
ANSI sequences to make the line in question disappear from the screen.
For something like a file-copy program that takes a filename
argument, the main program's input is the entire filesystem, and its
output is the entire (maybe modified) filesystem.
This turns out to be a huge (and automatic and unavoidable)
performance gain, as well as letting you to handle infinite-sized data
structures like "[1..]" (the list of all positive integers). However,
it also means changing the way we think about programming, which is
the hallmark of a worthwhile proramming language...
For these reasons, maybe Forth would be better as number 6, giving us
time to think about how to do pure I/O in an embedded environment...
M