Confusion about list types in Joy
Christopher Diggins — 2006-05-14 21:33:25
In Joy the expression:
[1 2 3]
Should have a type of "list of programs" but instead it has the type "list
of ints". I find this confusing. Do we just say in Joy, types are implied by
there context, and "1" can either be a program which returns a new stack
with one on the top, or it can be the integer "1" depending on the context.
Also, what is the history of the term "infra"?
[Non-text portions of this message have been removed]
John Cowan — 2006-05-15 16:04:58
Christopher Diggins scripsit:
> In Joy the expression:
>
> [1 2 3]
>
> Should have a type of "list of programs" but instead it has the type
> "list of ints". I find this confusing. Do we just say in Joy, types
> are implied by there context, and "1" can either be a program which
> returns a new stack with one on the top, or it can be the integer "1"
> depending on the context.
Yes, that's the nature of Joy. In Joy, data *is* code, as opposed to
the Lisp world in which a subset of data *represents* code.
--
John Cowan
cowan@... http://www.ccil.org/~cowan
O beautiful for patriot's dream that sees beyond the years
Thine alabaster cities gleam undimmed by human tears!
America! America! God mend thine every flaw,
Confirm thy soul in self-control, thy liberty in law!
-- one of the verses not usually taught in U.S. schools
Christopher Diggins — 2006-05-15 16:49:38
Hi John,
Consider the following:
sum = [+] fold;
[[1 2] sum] => [3]
[[1 dup] sum] => ???
There is a fundamental difference between the value 1 and the program which
pushes 1 onto the stack. Programs can't rationally support "+" but values
can.
On 5/15/06, John Cowan <cowan@...> wrote:
>
> Christopher Diggins scripsit:
>
> > In Joy the expression:
> >
> > [1 2 3]
> >
> > Should have a type of "list of programs" but instead it has the type
> > "list of ints". I find this confusing. Do we just say in Joy, types
> > are implied by there context, and "1" can either be a program which
> > returns a new stack with one on the top, or it can be the integer "1"
> > depending on the context.
>
> Yes, that's the nature of Joy. In Joy, data *is* code, as opposed to
> the Lisp world in which a subset of data *represents* code.
>
> --
> John Cowan cowan@... http://www.ccil.org/~cowan
> O beautiful for patriot's dream that sees beyond the years
> Thine alabaster cities gleam undimmed by human tears!
> America! America! God mend thine every flaw,
> Confirm thy soul in self-control, thy liberty in law!
> -- one of the verses not usually taught in U.S. schools
>
> ------------------------------
> YAHOO! GROUPS LINKS
>
>
> - Visit your group "concatenative<http://groups.yahoo.com/group/concatenative>"
> on the web.
>
> - To unsubscribe from this group, send an email to:
> concatenative-unsubscribe@yahoogroups.com<concatenative-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------
>
[Non-text portions of this message have been removed]
John Cowan — 2006-05-15 17:49:03
Christopher Diggins scripsit:
> sum = [+] fold;
>
> [[1 2] sum] => [3]
> [[1 dup] sum] => ???
>
> There is a fundamental difference between the value 1 and the program which
> pushes 1 onto the stack. Programs can't rationally support "+" but values
> can.
It's not the case that "[[1 2] sum]" evaluates to "[3]" -- it is in fact
self-evaluating -- although it is the case that "[1 2] sum" evaluates to "3".
Every Joy datum has a programmatic interpretation; a symbol is interpreted
as whatever the definition of that symbol might be, or the identity
function (or bottom, depending on the value of "undeferror") if it has
none; every other datum is interpreted as a function which pushes the
datum on the stack.
However, Joy programs are not necessarily total, and in particular the "+"
function cannot be applied to a stack whose topmost member is a symbol.
--
John Cowan
cowan@...
"You need a change: try Canada" "You need a change: try China"
--fortune cookies opened by a couple that I know
Christopher Diggins — 2006-05-16 15:12:22
Sergey Zubkov — 2006-05-16 15:40:23
On Tue, 16 May 2006, Christopher Diggins wrote:
> What I am doing in the Cat language instead is declaring all literals to be
> functions, and no different from any other function. This requires a special
> operator to convert from [1 2 3] to an actual list of integers.
> Any thoughts?
Does it have to be "an actual list of integers" though? That's a whole new
concept to add. Could those functions that put integers on stack simply be
executed when required by fold or map or whatever?
--Sergey Zubkov
John Cowan — 2006-05-16 16:53:00
Christopher Diggins scripsit:
> So the following is fine:
>
> define f = [1 1] + fold
>
> However the following is no good:
>
> define g = 1
> define f = [1 g] + fold
>
> The rationale being that "g" is a symbol versus a literal.
Not at all. The rationale is that "g" is a symbol, whereas "1" is a *number*
(or representations thereof, actually). Addition doesn't apply to symbols,
only to numbers.
In Joy, both symbols and numbers have a function interpretation as well as
a datum interpretation. This has nothing to do with their representations.
> What I am doing in the Cat language instead is declaring all literals to be
> functions, and no different from any other function. This requires a special
> operator to convert from [1 2 3] to an actual list of integers.
That IMHO misses the spirit of Joy. [1 2 3] has the functional interpretation
"push the datum [1 2 3] on the stack", like every other datum except a
symbol, whose functional interpretation is either "do the primitive function
named by the symbol" or else "retrieve the symbol's definition, which is a
list of datums, and apply each datum in turn to the stack".
--
A few times, I did some exuberant stomping about, John Cowan
like a hippo auditioning for Riverdance, though
cowan@...
I stopped when I thought I heard something at
http://ccil.org/~cowan
the far side of the room falling over in rhythm
with my feet. -- Joseph Zitt