Rahul | 1 Mar 2007 21:17
Picon

[stack] A question on joy syntax.

I have been looking through the joy papers, and have
this confusion:

The help on ifte says:

ifte [B] [T] [F] -> ...
Executes B. If that yields true, then executes T
else executes F.

Now the help on = says:
= X Y -> B
Either both X and Y are numeric or both are strings
or symbols. Tests whether X equal to Y. Also supports
float.

I assumed that '=' will consume two arguments off the stack,
and leave the true or false on top.

the joy interp seems to support this.

1 2 = .
false
.

Now, if I use the same inside an ifte
1 5 [1 =] [dup *] [dup +] ifte .
10

The doubt I have is this:
as soon as [1 =] is executed, I would expect '5' off the stack,
so the [dup +] should have actually found '1' on the stack and given
me 2.

I checked this too: which seems to do fine.
5 [true] [dup *] [dup +] ifte .
25

Is there a reason for this? Is for some reason the stack
invariant when executing ifte condition?
The below seems to verify it.

5 6 [pop 1 =] [dup *] [dup +] ifte .
12
.
5

But I cant find any info on this.
The other quoted programs does not seem to share the invariant stack
behavior:
================================
i [P] -> ...
Executes P. So, [P] i == P.

1 2 [1 +] i .
3
.
1

Could some one please explain why this is so? or guide me to the
docs that explains it?

rahul.

__._,_.___
Give Back

Yahoo! for Good

Get inspired

by a good cause.

Y! Toolbar

Get it Free!

easy 1-click access

to your groups.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
William Tanksley, Jr | 2 Mar 2007 06:15
Picon

Re: [stack] A question on joy syntax.

Rahul <blufox <at> gmail.com> wrote:
> I have been looking through the joy papers, and have
> this confusion:
> 1 5 [1 =] [dup *] [dup +] ifte .
> 10

> The doubt I have is this:
> as soon as [1 =] is executed, I would expect '5' off the stack,
> so the [dup +] should have actually found '1' on the stack and given
> me 2.

Yup. Me too. But that's not what Joy does; some of Joy's combinators
save the stack's state when they're performing certain types of
actions. You simply have to learn which ones do it and which ones
don't.

Sometimes this is very handy. Sometimes it's annoying.

> rahul.

-Billy

__._,_.___
SPONSORED LINKS
Search Ads

Get new customers.

List your web site

in Yahoo! Search.

Y! Toolbar

Get it Free!

easy 1-click access

to your groups.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Rahul | 2 Mar 2007 20:36
Picon

[stack] New language V (on JVM)

Hi,
First (alpha) release of V is available here
http://v-language.googlecode.com/files/v_0.001.jar
It is nothing more than a dialect of Joy at this point
(with some differences).

Only a few of the primitives are available:
[?(peek),??(show stack),.(define word)
!=, *,+,-,/,<,<=,=,>,>=,and,concat,cons,dip,dup,false
fold,i,map,not,or,pop,put,rolldown,rollup,swap,true
uncons,while]

More information is available here
http://v-language.googlecode.com/svn/trunk/v/status.txt

I hope to add an FFI for callout to java and a stack shuffling
operator soon.

Please do take a look, (I am just learning the theory and
implementing as I go along).
rahul

__._,_.___
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Need traffic?

Drive customers

With search ads

on Yahoo!

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Joe Bowbeer | 2 Mar 2007 22:50
Picon
Gravatar

Re: [stack] New language V (on JVM)

I love to see languages running on the JVM.

A couple of pointers just in case you're not aware:

1. Consider binding your implementation to the scripting framework:

http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/

https://scripting.dev.java.net/

2. Consider adding your implementation to the list of Languages for the JVM:

http://www.robert-tolksdorf.de/vmlanguages.html

--Joe

On 3/2/07, Rahul <blufox <at> gmail.com> wrote:
> Hi,
> First (alpha) release of V is available here
> http://v-language.googlecode.com/files/v_0.001.jar
> It is nothing more than a dialect of Joy at this point
> (with some differences).
>
> Only a few of the primitives are available:
> [?(peek),??(show stack),.(define word)
> !=, *,+,-,/,<,<=,=,>,>=,and,concat,cons,dip,dup,false
> fold,i,map,not,or,pop,put,rolldown,rollup,swap,true
> uncons,while]
>
> More information is available here
> http://v-language.googlecode.com/svn/trunk/v/status.txt
>
> I hope to add an FFI for callout to java and a stack shuffling
> operator soon.
>
> Please do take a look, (I am just learning the theory and
> implementing as I go along).
> rahul
>

__._,_.___
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

New web site?

Drive traffic now.

Get your business

on Yahoo! search.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
William Tanksley, Jr | 2 Mar 2007 23:11
Picon

Re: [stack] New language V (on JVM)

Rahul <blufox <at> gmail.com> wrote:
> First (alpha) release of V is available here
> http://v-language.googlecode.com/files/v_0.001.jar

Cool, congrats on nice progress.

> It is nothing more than a dialect of Joy at this point
> (with some differences).

Curiosity: what's your goals?

Your definition syntax looks nice, by the way. Simple and clean...
Although I suppose one could complain that it's hard to visually
discern definitions from random blocks of code, I think it'll be
pretty rare to just have a random block of code.

Can definitions be constructed at runtime? Is "." a normal word or is it syntax?

> I hope to add an FFI for callout to java

Good idea, of course.

I've occasionally wondered what a concatenative language modeled to
take advantage of the JVM would look like. I recall that the JVM isn't
totally stack-centered; it has a lot of machinery for stack frames as
well.

> Please do take a look, (I am just learning the theory and
> implementing as I go along).

Looks nice. This is probably a good way to learn.

> rahul

-Billy

__._,_.___
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

New business?

Get new customers.

List your web site

in Yahoo! Search.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
William Tanksley, Jr | 3 Mar 2007 02:33
Picon

Re: Re: [stack] S-K Construction of Dip?

Brent L Kerby <bkerby <at> byu.net> wrote:
> > I find it interesting that completeness is different between
> > applicative and concatenative languages (for example, {s,k} is a
> > complete applicative basis, but not is not complete when
> > concatenative).

> Right. When we map the applicative combinators to concatenative
> ones in the obvious way, the image of this map is not a complete
> (concatenative) set. But it's interesting to note that, in the other
> direction, things turn out differently. I.e., the image of the natural
> map (or at least, what I'm calling the natural map) from
> concatenative combinators to applicative ones _is_, remarkably
> enough, a complete applicative set.

This would seem to generally fit my theory -- that applicative syntax
is more powerful in its greater complexity, because an applicative
syntax allows a language to directly express the concept of
"siblings". Whenever a function takes two parameters, those parameters
are "siblings". The only way to connote the concept of siblings in a
concatenative language is to build the putative siblings into a list.

> So there we have it! The image of P is a complete applicative set!
> What is perhaps even more surprising is that we didn't need to
> use the image of "i" or "dip".

I noticed the lack of need for "i" much earlier. At first I thought
this was a problem with our notation (since the applicative notation
doesn't even have a concept of dequotation), but I believe now that
it's not a problem: it's a result of how concatenative notation can't
denote siblings, so a runtime concept (quotation) must take its place.

> In any case, note that I'm not claiming P is surjective
> (i.e., that it maps onto to every applicative combinator),
> only that it maps onto a complete subset of the applicative
> combinators.

I know many of those terms, but I don't know what "complete subset"
means. Does it mean "a subset of combinators which includes a complete
base"? If so, that makes sense.

> If P (or rather, the version of P which operates on equivalence
> classes of lambda-forms rather than the forms themselves --
> call it P^, "P-hat") is surjective, then it would be an isomorphism
> between the concatenative and applicative systems of
> combinators (the well-definedness and injectivity of P^ follow from
> the fact that P respects reduction). I doubt that such an isomorphism
> exists but don't know how to prove this. This is really the fundamental
> question about the relationship between concatenative and
> applicative combinators: are the two systems isomorphic?

This last question definitely nags at me in one way, which I can't
define. I have a nagging doubt that we're missing something.

In another way it seems evident (after much exploration) that the
systems are "equivalent" (in the sense that a program in one can
always be expressed in the other). But I don't know too much about
isomorphism, except that it's more complex than that... I've only had
a general undergrad intro to modern algebra (groups, fields, algebras,
etc).

> For this argument, I'm using a special case of the
> Church-Rosser property, that an (applicative) combinator
> has a unique normal form (i.e., a form with no redexes) if
> it has one at all. (The general case states that if A, B, and
> C are lambda-forms with A=>B and A=>C, then there is a
> form D such that B=>D and C=>D. This essentially says
> that if you can get a form to reduce to two different forms
> (by choosing different redexes to reduce), you can perform
> further reduction to converge again to a common form. This
> an intuitive idea which is nevertheless highly non-trivial to
> prove). Although I'm not relying on it here, it would also be
> nice to know if an analogous "Church-Rosser" property holds
> for concatenative combinators.

Is this something of what you mean by "isomorphism"? That would indeed
be an awesome property. There are a lot of very simple things that are
obvious about flat concatenative languages (for example, it makes
sense that once you understand the meaning of a bitstring without
context, you therefore know its meaning in any context), but there are
also a lot of things that seem to take more work to parse out (for
example, some "optimizations" seem to be very complex to express
formally).

(Sorry for the informal terminology. I'm very new at this.)

> > [B] [A] cake == [[B] A] [A [B]]

> > Clearly, A and B are not siblings here. Of course, constructing concat
> > is possible, which obviously makes siblings out of A and B, but is it
> > somehow less theoretically pure to have a basis in which the siblings
> > are not explicit in the provided basis combinators?

> Well, the construction of "cat" in terms of {cake,k} relies on transparent
> quotation; ultimately, it's the same construction as this one from i, dip,
> and cons:

Ah! And this helps me understand what "transparent quotation" means at
a semantic level. My implementation (01.py) clearly uses transparent
quotation, since it executes combinators at the earliest opportunity
(in fact, I think it actually might execute them too soon... I need to
work on that).

>Therefore, "cat" is inconstructible in {cake,k} under opaque
>quotation. So, {cake,k} is not complete in as strong a sense
>as, for example, {q,k} (from which all combinators are constructible,
>even assuming opaque quotation):

YES! I'm starting to "get it".

> In addition, I'd say "q" is a bit nicer than "cake" since, aside from
> being simpler, it has the pretty property that it produces a (unit)
> quotation and a concatenation, which correspond precisely to
> the two syntactic constructions of the language. This may not
> be particularly significant in the grand scheme of things, but we
> have to admit that it's a bit nifty.

Hmmm... I'm a ways from being knowledgable enough to be able to admit
that. I'll take your word for it, after I play around with your
joys.exe program a bit more. I'm not sure how I'm going to get any
different results; in particular, getting a concat seems to be
essential to completeness. I suspect that the only way to do anything
else would be to have a combinator which took more parameters (and
that just seems like it'd be less efficient).

Hmm again.

> So I'm perfectly fine with "condemning {cake,k} to contempt and
> contumely" :-)

It's one of the things I'm qualified to do, having studied ancient literature.

Would you like fries with that?

> - Brent

-Billy

__._,_.___
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Ads on Yahoo!

Learn more now.

Reach customers

searching for you.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Rahul | 3 Mar 2007 09:46
Picon

Re: [stack] New language V (on JVM)

Jr" <wtanksleyjr <at> ...> wrote:

> Curiosity: what's your goals?

dont have any goals (other than minimal syntax - (just '[' and ']'))
for now, I think I will let the language evolve and see where it goes.

> Your definition syntax looks nice, by the way. Simple and clean...

thanks,

> Although I suppose one could complain that it's hard to visually
> discern definitions from random blocks of code, I think it'll be
> pretty rare to just have a random block of code.

I agree it is hard to see definitions if it is inside an unformated
block of code but usually users format and delimit definitions
with empty lines comment headers and such,
I hope it would not prove to be a bad decision.

> Can definitions be constructed at runtime? Is "." a normal word or
is it syntax?

. is just a normal word.
|[hi] ['hello' puts] concat .
|hi
=hello

> I've occasionally wondered what a concatenative language modeled to
> take advantage of the JVM would look like. I recall that the JVM
isn't
> totally stack-centered; it has a lot of machinery for stack frames
as
> well.

__._,_.___
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Need traffic?

Drive customers

With search ads

on Yahoo!

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Rahul | 3 Mar 2007 10:33
Picon

Re: [stack] New language V (on JVM)

--- "Joe Bowbeer" <joe.bowbeer <at> ...>
wrote:
> 1. Consider binding your implementation to the scripting framework:
> http://java.sun.com/developer/technicalArticles/J2SE/Desktop/
scripting/
> https://scripting.dev.java.net/

I was hopping to do it along with the FFI to java.

> 2. Consider adding your implementation to the list of Languages for
the JVM:
>
> http://www.robert-tolksdorf.de/vmlanguages.html

Thanks I have done that now.
rahul

__._,_.___
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

New business?

Get new customers.

List your web site

in Yahoo! Search.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Taoufik Dachraoui | 3 Mar 2007 11:59
Picon

Re: [stack] A question on joy syntax.

I tried to define ifte as it is implemented in joy1 and I found this:

[T] [A] [B]
ifte == [[[stack] dip] dip
[dip swap] dip] dip #save stack and run T
choice [unstack] dip i; # restore stack and choose
between A and B

The stack is saved before the execution of [T] and restored before the
execution of [A] or [B]. The test in this case is non destructive;
the stack
is unchanged before choosing between A and B.

The way you implmented ifte is as follows:

[T] [A] [B]
ifte == [[i] dip] dip #run T
choice i; # choose between A and B

Obviously your implementation is faster, but the test in this case
is destructive; the stack can be modified greatly depending on T.

Is it more difficult or easier to reason with destructive tests?

Taoufik

On Mar 1, 2007, at 9:17 PM, Rahul wrote:

> I have been looking through the joy papers, and have
> this confusion:
>
> The help on ifte says:
>
> ifte [B] [T] [F] -> ...
> Executes B. If that yields true, then executes T
> else executes F.
>
> Now the help on = says:
> = X Y -> B
> Either both X and Y are numeric or both are strings
> or symbols. Tests whether X equal to Y. Also supports
> float.
>
> I assumed that '=' will consume two arguments off the stack,
> and leave the true or false on top.
>
> the joy interp seems to support this.
>
> 1 2 = .
> false
> .
>
> Now, if I use the same inside an ifte
> 1 5 [1 =] [dup *] [dup +] ifte .
> 10
>
> The doubt I have is this:
> as soon as [1 =] is executed, I would expect '5' off the stack,
> so the [dup +] should have actually found '1' on the stack and given
> me 2.
>
> I checked this too: which seems to do fine.
> 5 [true] [dup *] [dup +] ifte .
> 25
>
> Is there a reason for this? Is for some reason the stack
> invariant when executing ifte condition?
> The below seems to verify it.
>
> 5 6 [pop 1 =] [dup *] [dup +] ifte .
> 12
> .
> 5
>
> But I cant find any info on this.
> The other quoted programs does not seem to share the invariant stack
> behavior:
> ================================
> i [P] -> ...
> Executes P. So, [P] i == P.
>
> 1 2 [1 +] i .
> 3
> .
> 1
>
> Could some one please explain why this is so? or guide me to the
> docs that explains it?
>
> rahul.
>
>
>

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

__._,_.___
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Y! Toolbar

Get it Free!

easy 1-click access

to your groups.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Taoufik Dachraoui | 3 Mar 2007 12:37
Picon

Re: [stack] A question on joy syntax.

looking at the defintion of factorial:

in Joy:
fact == [0 =] [pop 1] [dup 1 - fact *] ifte

in v:
[fact
[dup 0 =]
[pop 1]
[dup 1 - fact *]
ifte].

In the second definition we explicitly manipulate the stack (dup) so
that the remaining code finds the stack in the expected state. In
this case dup is certainly faster than saving and restoring the
stack, but in other situations this may not be true.

Taoufik

On Mar 3, 2007, at 11:59 AM, Taoufik Dachraoui wrote:

> I tried to define ifte as it is implemented in joy1 and I found this:
>
> [T] [A] [B]
> ifte == [[[stack] dip] dip
> [dip swap] dip] dip #save stack and run T
> choice [unstack] dip i; # restore stack and choose
> between A and B
>
> The stack is saved before the execution of [T] and restored before the
> execution of [A] or [B]. The test in this case is non destructive;
> the stack
> is unchanged before choosing between A and B.
>
> The way you implmented ifte is as follows:
>
> [T] [A] [B]
> ifte == [[i] dip] dip #run T
> choice i; # choose between A and B
>
> Obviously your implementation is faster, but the test in this case
> is destructive; the stack can be modified greatly depending on T.
>
> Is it more difficult or easier to reason with destructive tests?
>
> Taoufik
>
> On Mar 1, 2007, at 9:17 PM, Rahul wrote:
>
> > I have been looking through the joy papers, and have
> > this confusion:
> >
> > The help on ifte says:
> >
> > ifte [B] [T] [F] -> ...
> > Executes B. If that yields true, then executes T
> > else executes F.
> >
> > Now the help on = says:
> > = X Y -> B
> > Either both X and Y are numeric or both are strings
> > or symbols. Tests whether X equal to Y. Also supports
> > float.
> >
> > I assumed that '=' will consume two arguments off the stack,
> > and leave the true or false on top.
> >
> > the joy interp seems to support this.
> >
> > 1 2 = .
> > false
> > .
> >
> > Now, if I use the same inside an ifte
> > 1 5 [1 =] [dup *] [dup +] ifte .
> > 10
> >
> > The doubt I have is this:
> > as soon as [1 =] is executed, I would expect '5' off the stack,
> > so the [dup +] should have actually found '1' on the stack and given
> > me 2.
> >
> > I checked this too: which seems to do fine.
> > 5 [true] [dup *] [dup +] ifte .
> > 25
> >
> > Is there a reason for this? Is for some reason the stack
> > invariant when executing ifte condition?
> > The below seems to verify it.
> >
> > 5 6 [pop 1 =] [dup *] [dup +] ifte .
> > 12
> > .
> > 5
> >
> > But I cant find any info on this.
> > The other quoted programs does not seem to share the invariant stack
> > behavior:
> > ================================
> > i [P] -> ...
> > Executes P. So, [P] i == P.
> >
> > 1 2 [1 +] i .
> > 3
> > .
> > 1
> >
> > Could some one please explain why this is so? or guide me to the
> > docs that explains it?
> >
> > rahul.
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
>
>

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

__._,_.___
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Ads on Yahoo!

Learn more now.

Reach customers

searching for you.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___

Gmane