William Tanksley | 3 Mar 2009 16:11
Picon

Re: [stack] What does "concatenative" actually mean?

John Nowak wrote:
> The object systems in Factor and Forth do break referential
> transparency. If this means that are not "purely concatenative"
> depends on who you ask.

Thanks for taking the time to explain; I agree with most of what you've
said, but this is false.

Forth doesn't have any "the object system"; some of the open-source
alternatives available do destroy local concatenativity, but most of
them don't.

Factor's official object system is definitely fully concatenative. It
won't matter who you ask; if they disagree with me, they're wrong. ;-)

Technical point: Referential Transparency in a concatenative language is
different from the same concept in an applicative language. In one
sense, it's harder to use, since you can't simply move words from one
place to another (without rearranging the stack); in another sense it's
easier to use, since you can "factor out" a word without having to do
any work at all (cut and paste is sufficient). Unlike applicative
languages, you do NOT have to worry about functional state; the fact
that the stack acts as a monad means that the state is already
preserved; even I/O can be modelled properly.

> - John

-Wm

__._,_.___
Recent Activity
Visit Your Group
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.

.

__,_._,___
John Nowak | 3 Mar 2009 20:16
Gravatar

Re: [stack] What does "concatenative" actually mean?

On Mar 3, 2009, at 10:11 AM, William Tanksley wrote:

> Factor's official object system is definitely fully concatenative. It
> won't matter who you ask; if they disagree with me, they're wrong. ;-)
>
> Technical point: Referential Transparency in a concatenative
> language is
> different from the same concept in an applicative language. In one
> sense, it's harder to use, since you can't simply move words from one
> place to another (without rearranging the stack); in another sense
> it's
> easier to use, since you can "factor out" a word without having to do
> any work at all (cut and paste is sufficient). Unlike applicative
> languages, you do NOT have to worry about functional state; the fact
> that the stack acts as a monad means that the state is already
> preserved; even I/O can be modelled properly.

Not everyone agrees on this point. Take a look at this thread:

http://lambda-the-ultimate.org/node/3050

Many would say Joy is not purely functional and that the "monadic
stack" argument essentially amounts to hand-waving. If you take this
view, then the question of Joy or Factor being "purely concatenative"
depends on if you require concatenative languages to be "purely
functional".

Joy isn't "pure enough" to allow evaluation via postfix term rewriting
in an arbitrary order. If you had a type system that could enforce
something similar to the I/O monad in Haskell, it would be. I
definitely think there's some use in distinguishing between the
relative purity of both approaches.

I feel that being able to evaluate in any order without worrying about
side effects is somehow "more concatenative" than having to evaluate
left to right. Rather than make a claim here, I tried to sidestep the
issue to avoid contention. I see I failed once again! :)

- John

__._,_.___
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

New web site?

Drive traffic now.

Get your business

on Yahoo! search.

John McEnroe

on Yahoo! Groups

Join him for the

10 Day Challenge.

.

__,_._,___
William Tanksley | 4 Mar 2009 22:59
Picon

Re: [stack] What does "concatenative" actually mean?

John Nowak wrote:
> William Tanksley wrote:
> > Technical point: Referential Transparency in a concatenative
> > language is
> > different from the same concept in an applicative language. In one
> > sense, it's harder to use, since you can't simply move words from one
> > place to another (without rearranging the stack); in another sense
> > it's
> > easier to use, since you can "factor out" a word without having to do
> > any work at all (cut and paste is sufficient). Unlike applicative
> > languages, you do NOT have to worry about functional state; the fact
> > that the stack acts as a monad means that the state is already
> > preserved; even I/O can be modelled properly.

> Not everyone agrees on this point. Take a look at this thread:
> http://lambda-the-ultimate.org/node/3050

I think they're trying to discuss how not all concatenative languages
need to be functional and vice versa... A point I've made myself just
recently. But you're right to correct me when I use the technical term
"referential transparency" in an inappropriate way. Only purely
functional languages can be referentially transparent.

> Many would say Joy is not purely functional

I agree with them.

> and that the "monadic
> stack" argument essentially amounts to hand-waving.

There's a lot more details to be worked out, but the essence is true --
linear logic with data items on a stack impose an order on computation.
Extracting that order is not a completely solved problem, and it's
always been an item of interest to me.

I'm often overly impatient about figuring it out -- that makes me say
things like "the stack is a monad, concatenative languages need nothing
else." I'm wrong to say that; it's more complicated than that. But a
naive concatenative language (i.e. one that executes strictly in order)
needs nothing else; and a sophisticated one needs only as much
sophistication as its out-of-order execution can handle.

> If you take this
> view, then the question of Joy or Factor being "purely concatenative"
> depends on if you require concatenative languages to be "purely
> functional".

As you can see, I don't require that. My definition of "concatenative"
implies and requires associativity in syntax and semantics; it doesn't
mention functionality. A purely concatenative language may be highly
stateful, and thus not a functional language. It may be zeroeth order,
and therefore not a function-level language. It's still concatenative.

Joy is supposed to be somewhat functional -- if von Thun had intended it
to be purely functional he would have done something different with I/O.
Factor makes no claims as to functionality, just practicality, so the
"question" has never been raised.

> Joy isn't "pure enough" to allow evaluation via postfix term rewriting
> in an arbitrary order. If you had a type system that could enforce
> something similar to the I/O monad in Haskell, it would be. I
> definitely think there's some use in distinguishing between the
> relative purity of both approaches.

I entirely agree; that's why it's essential to maintain a distinction
between "purely functional" and "purely concatenative". You can have
both, neither, or either. There are benefits and prices for all
combinations.

> I feel that being able to evaluate in any order without worrying about
> side effects is somehow "more concatenative" than having to evaluate
> left to right. Rather than make a claim here, I tried to sidestep the
> issue to avoid contention. I see I failed once again! :)

You'll not escape me! :)

I'd disagree that it's more concatenative to be able to evaluate in any
order. It is certainly more functional (or declarative), though. And
there IS value to it. The problem is that there's also a price to be
paid, and not every programmer wants to pay it.

In reality, the stack is not the only thing that gets passed to every
function. In every practical concatenative language so far invented
there's always something else -- sometimes a dictionary, sometimes an
I/O device... Often an entire virtual machine. There's value in
simplifying this machine (following a functional approach), and there's
value in clearly characterizing it (following a formal approach). One
need not do either.

For an example of how a more functional approach simplified a language,
consider Joy's introduction of 'dip', which entirely eliminated the need
for Forth's programmer-editable return stack. Of course, the return
stack or something like it is still hiding in the background; stevan's
XY language makes its replacement explicit, but in both cases it remains
a part of the global state, just like the data stack.

> - John

-Wm

__._,_.___
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

New web site?

Drive traffic now.

Get your business

on Yahoo! search.

Everyday Wellness

on Yahoo! Groups

Find groups that will

help you stay fit.

.

__,_._,___
John Nowak | 4 Mar 2009 23:37
Gravatar

Re: [stack] What does "concatenative" actually mean?


On Mar 4, 2009, at 4:59 PM, William Tanksley wrote:

> I'm often overly impatient about figuring it out -- that makes me say
> things like "the stack is a monad, concatenative languages need
> nothing
> else." I'm wrong to say that; it's more complicated than that. But a
> naive concatenative language (i.e. one that executes strictly in
> order)
> needs nothing else; and a sophisticated one needs only as much
> sophistication as its out-of-order execution can handle.

You're right, but I don't think this applies just to concatenative
languages. I may be misunderstanding what you're saying, but let me
clarify my point anyway.

Take the Scheme expression '(+ (+ 1 2) (+ 2 3))'. Instead of '()'
meaning application, we'll have it form a function that, when applied
to a world value, returns a tuple of a new world value and the result
of the expression. To reduce within a function formed by '()', the
function receiving the world would pass it to the left-most '()'
within it, get the tuple of the world and result back, save the
result, and pass the world to the next '()' within it. At the top
level of our program, we'll apply our function to the world value to
kick things off.

What I'm trying to say is that, with a bit of hand-waving, you can
make any language "purely functional" just by describing how the world
value would be threaded through the application. It should be obvious
though that this isn't particularly useful if it lets us claim that,
say, C is purely functional (which it would).

Threading a world value around is only useful if you *don't* pass it
to everything. The functions that don't need it can be evaluated and
reasoned about without caring about it.

You are 100% right that the monadic nature of concatenative code makes
linearity easier. Henry Baker would certainly agree. I think it also
may have the potential to make Haskell-style monadic code more natural
thanks to the left-to-right syntax.

I'm not even sure if I'm disagreeing with you; I just think we should
probably be a bit more careful with our claims. I'm certainly included
in that "we". In fact, I may have made some bogus claims related to
this very topic not so long ago.

> Joy is supposed to be somewhat functional -- if von Thun had
> intended it
> to be purely functional he would have done something different with
> I/O.

Manfred von Thun has, as far as I know, always claimed that Joy is
purely functional. Numerous articles on the Joy site make this claim,
the Wikipedia article for Joy makes this claim, et cetera. After
giving this some thought, I really do think it is misleading. Perhaps
Manfred meant to exclude IO from him claim; I've seen some evidence
for this, namely in the interview on NSL, but I don't want to guess at
his meaning.

> I entirely agree; that's why it's essential to maintain a distinction
> between "purely functional" and "purely concatenative". You can have
> both, neither, or either. There are benefits and prices for all
> combinations.

I completely agree with your distinction.

>> I feel that being able to evaluate in any order without worrying
>> about
>> side effects is somehow "more concatenative" than having to evaluate
>> left to right. Rather than make a claim here, I tried to sidestep the
>> issue to avoid contention.
>
> I'd disagree that it's more concatenative to be able to evaluate in
> any
> order. It is certainly more functional (or declarative), though. And
> there IS value to it. The problem is that there's also a price to be
> paid, and not every programmer wants to pay it.

Again, I agree. This is a good way of breaking down the situation.

- John

__._,_.___
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Ads on Yahoo!

Learn more now.

Reach customers

searching for you.

Group Charity

City Year

Young people who

change the world

.

__,_._,___
John Cowan | 4 Mar 2009 23:55

Re: [stack] What does "concatenative" actually mean?

John Nowak scripsit:

> Manfred von Thun has, as far as I know, always claimed that Joy is
> purely functional. Numerous articles on the Joy site make this claim,
> the Wikipedia article for Joy makes this claim, et cetera. After
> giving this some thought, I really do think it is misleading. Perhaps
> Manfred meant to exclude IO from him claim; I've seen some evidence
> for this, namely in the interview on NSL, but I don't want to guess at
> his meaning.

To be fair, most of those claims predate the addition of input to Joy,
which happened when I reworked Joy0 into Joy1, the current version
with the file I/O, random numbers, clock time, and command-line args.
Before that, the only I/O function was ".", which outputs the top of
stack; by itself, that doesn't make Joy0 not purely functional.

--
Barry gules and argent of seven and six, John Cowan
on a canton azure fifty molets of the second. cowan <at> ccil.org
--blazoning the U.S. flag http://www.ccil.org/~cowan

__._,_.___
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Search Ads

Get new customers.

List your web site

in Yahoo! Search.

Health Groups

for people over 40

Join people who are

staying in shape.

.

__,_._,___
John Nowak | 5 Mar 2009 00:05
Gravatar

Re: [stack] What does "concatenative" actually mean?


On Mar 4, 2009, at 5:55 PM, John Cowan wrote:

> To be fair, most of those claims predate the addition of input to Joy,
> which happened when I reworked Joy0 into Joy1, the current version
> with the file I/O, random numbers, clock time, and command-line args.
> Before that, the only I/O function was ".", which outputs the top of
> stack; by itself, that doesn't make Joy0 not purely functional.

Good to know. Relatively speaking, I'm late to the game here.

- John

__._,_.___
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

New web site?

Drive traffic now.

Get your business

on Yahoo! search.

Get in Shape

on Yahoo! Groups

Find a buddy

and lose weight.

.

__,_._,___

Gmane