Discussion:
[stack] Sieve of Eratosthenes
Ruurd
2011-12-09 10:20:47 UTC
Permalink
The Sieve has been mentioned before in this newsgroup, but I didn't see a solution in Joy. Here is my proposal.

(* popen ( Q -> )
Ruurd
2011-12-09 10:32:19 UTC
Permalink
The Sieve of Eratosthenes has been mentioned earlier in this newsgroup, but I didn't see a solution in Joy. Here is mine:

(*
popen ( Q -> ) starts a new task. The stdout of the current
task is connected to the stdin of the new task.
*)
DEFINE sieve == get dup put [sieve] popen
[] [get [swap mod] [put] [pop] ifte] while.

DEFINE count == 2 [] [dup put succ] while.

[sieve] popen count.

Of course, there is no such thing as a multi-tasking version of Joy,
but maybe this example shows that it worth the trouble building such
a thing. Is it?
William Tanksley, Jr
2011-12-09 15:57:45 UTC
Permalink
A message-passing multiprocess Joy would be interesting indeed.

I know of two innately multiprocessing concatenative languages,
Enchilada and Ripple. Both depend on multiprocessing behavior
(although I'm not sure that either one currently USES multiple
processes or threads). Ripple is the more extensively developed of the
two; Enchilada is a research project.

-Wm
Ruurd
2011-12-10 10:04:36 UTC
Permalink
Post by William Tanksley, Jr
I know of two innately multiprocessing concatenative languages,
Enchilada and Ripple.
-Wm
Another example is Niue: http://vmathew.in/niue/docs/niue-lang.pdf

It uses !! (spawn) Executes a code block in a new process.
Pushes the process id of the new process on to
the data stack of the parent.

I am a bit worried about having to keep track of those process id's
and I am not convinced that it must be asynchronous message passing.
Also, the Sieve example:
http://rosettacode.org/wiki/Sieve_of_Eratosthenes#Niue
does not use the message passing.

Simon Kongshøj
2011-12-09 17:05:11 UTC
Permalink
One of my hobby projects when I was working on my master's thesis was Merlin, a combination of a concatenative sequential language and an Actor-based concurrency system.

The idea was to have simple asynchronous message-passing similar to that of Erlang, but rather than using pattern matching on a "mailbox", the semantics of the "receive" operator would be to simply place a message from the "mailbox" on top of the stack. Each actor then consisted of a data stack, a return stack, and a mailbox. The concatenative, sequential sublanguage was purely functional, and state was entirely a property of the fact that actors can replace their stacks in response to messages, so everything that was stateful was an actor, and everything else was immutable.

When I started tinkering on it, I didn't really know anything about concatenative languages, apart from having hacked some Forth code on my Amiga way back when, and having once learned to code in PostScript. My favourite languages being Forth and Lisp, I tried to hybridize them, and - not surprisingly - I ended up with something that resembled Joy quite a lot. When I became aware of Joy, I changed some bits of sequential Merlin to be more Joy-like, when I liked Joy's solutions better than my own (for instance, I didn't have polymorphic operators that worked on both numbers and lists, like Joy does, but I liked that, so I ripped it off), and ended up with something that could probably justifiably be called a dialect of Joy.

Unfortunately, I ended up rewriting the whole implementation several times, because I kept being unsatisfied with it. I don't have much time to hack on it anymore; my PhD work takes up most of my time. I should probably try to find time to tidy up my old code, fix up the remaining flaws and put it up somewhere for others to play with.

Regards,
Simon


[Non-text portions of this message have been removed]
Loading...