special operator labels in common lisp
icpdesign — 2005-10-14 19:41:39
Common lisp has a special operator labels used as the following:
(defun recursive-times (k n)
(labels ((temp (n)
(if (zerop n) 0 (+ k (temp (1- n))))))
(temp n))) => RECURSIVE-TIMES
(recursive-times 2 3) => 6
This recursive function can be defined in Joy as follows:
rt == [0 =] [pop pop 0] [[dup] dip 1 - rt +] ifte;
But if we had a label operator defines as:
L [P] label : where L is a string and P is a program that
may contain recursive calls to P using the label L.
the label operator binds the program P to a name (L intern)
and the scope of the label is the program P, and with the
program P we can use L to recursively call P.
we could use label operator as follows:
"rt" [[0 =] [pop pop 0] [[dup] dip 1 - rt +] ifte] label
Also, the label operator allows us to write loops and to define
all (?) the existing recursive combinators (binrec, linrec,....)
Any thoughts about adding the label operator to Joy
Kind reagrds
Taoufik
William Tanksley, Jr — 2005-10-15 02:40:21
icpdesign <
taoufik.dachraoui@...> wrote:
> Any thoughts about adding the label operator to Joy
Joy already has it, although with a slightly different syntax.
> Taoufik
-Billy
icpdesign — 2005-10-15 11:57:12
--- In
concatenative@yahoogroups.com, "William Tanksley, Jr" <wtanksleyjr@g...> wrote:
>
> icpdesign <taoufik.dachraoui@w...> wrote:
> > Any thoughts about adding the label operator to Joy
>
> Joy already has it, although with a slightly different syntax.
I could not find it, can you please tell which operator it is
>
> > Taoufik
>
> -Billy
>
kind regards
-Taoufik
William Tanksley, Jr — 2005-10-15 22:25:34
icpdesign <
taoufik.dachraoui@...> wrote:
> --- In concatenative@yahoogroups.com, "William Tanksley, Jr" <wtanksleyjr@g...> wrote:
> > icpdesign <taoufik.dachraoui@w...> wrote:
> > > Any thoughts about adding the label operator to Joy
> > Joy already has it, although with a slightly different syntax.
> I could not find it, can you please tell which operator it is
The == and scope control operators should serve nicely, and as a bonus
will allow you to use your labels in other words.
I admit that they're not as Lisplike as your suggestion, but they work
well enough, and Joy's purpose is limited -- it's not trying to be a
generally cool language, but rather a demonstration of what a language
based on concatenative principles could be.
There's plenty of room for a Lisplike concatenative language... I'd
like to see it. Although personally, I'm more interested in exploring
in other directions.
> -Taoufik
-Billy