Christopher Diggins | 1 Jul 01:24 2006
Picon

[stack] Version 0.3 of the Cat Programming Language

There is now a new version of the Cat programming language online at
http://www.cdiggins.com/cat/cat.zip .
There have been some syntax changes, which I explain briefly at
http://www.artima.com/weblogs/viewpost.jsp?thread=166952

- Christopher Diggins

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

------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/concatenative/

<*> To unsubscribe from this group, send an email to:
    concatenative-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

stevan apter | 1 Jul 05:17 2006

Re: [stack] Re: 'stack' and 'unstack' in F


----- Original Message ----- 
From: "William Tanksley, Jr" <wtanksleyjr <at> gmail.com>
To: <concatenative <at> yahoogroups.com>
Sent: Friday, June 30, 2006 5:19 PM
Subject: Re: [stack] Re: 'stack' and 'unstack' in F

> stevan apter <sa <at> nsl.com> wrote:
> > > I'll prove by counterexample that it's untrue: I can define a language
> > > in which 'stack' could be defined without any variable valence
> > > primitives -- not even a variable loop. This hypothetical language has
> > > a stack that's a constant depth (probably a circular buffer), so
> > > saving it to an array requires a constant number of operations. This
> > > is an extreme counterexample, and I suspect that some gentler one
> > > probably exists -- but at the same time, note that one concatenative
> > > language actually works this way (Chuck Moore's machine forth and
> > > colorforth).
> 
> > wow - a circular stack - a stircle.
> 
> Heh, yup. No suprise that Chuck would have used one -- engineers are
> always using circular buffers. (schtuffers?)

so >r and r> rotate the stack left and right one position?  a nice
way to store/retrieve things.  (i'm almost kidding - i wouldn't expect
moore to do this .. but i would!)

> 
> > > I just thought of a gentler counterexample: a primitive named 'empty?'
> > > could be used to implement 'stack'. It returns true when the stack is
(Continue reading)

William Tanksley, Jr | 1 Jul 10:00 2006
Picon

Re: [stack] Re: 'stack' and 'unstack' in F

stevan apter <sa <at> nsl.com> wrote:

I'll be gone for a week -- one final message:

> > stevan apter <sa <at> nsl.com> wrote:
> > Heh, yup. No suprise that Chuck would have used one -- engineers are
> > always using circular buffers. (schtuffers?)

> so >r and r> rotate the stack left and right one position?  a nice
> way to store/retrieve things.  (i'm almost kidding - i wouldn't expect
> moore to do this .. but i would!)

'drop' rotates the stack one element, of course... I don't know
whether there's a word to rotate it the other way.

> > > > I just thought of a gentler counterexample: a primitive named 'empty?'
> > > > could be used to implement 'stack'. It returns true when the stack is
> > > > empty, false otherwise. Its valence is undetectably close to zero,
> > > > because it doesn't actually consume anything; its charge is a constant
> > > > 1. (It's not as good of a counterexample as my previous one, because
> > > > it may be argued that its valence is 1 when the stack's full and 0
> > > > when the stack's empty -- but that would be a pretty subtle argument.)

> > > 'empty?' takes the entire stack as an argument, returns 1 if it's
> > > empty, else 0.  so in my lingo, it has infinite valence.

> > In your lingo, then, every one of your primitives has infinite valence
> > -- they also take the entire stack as an argument and branch based on
> > whether it's full or empty. Right?

(Continue reading)

stevan apter | 1 Jul 14:51 2006

Re: [stack] Re: 'stack' and 'unstack' in F


----- Original Message ----- 
From: "William Tanksley, Jr" <wtanksleyjr <at> gmail.com>
To: <concatenative <at> yahoogroups.com>
Sent: Saturday, July 01, 2006 4:00 AM
Subject: Re: [stack] Re: 'stack' and 'unstack' in F

> stevan apter <sa <at> nsl.com> wrote:
> 
> I'll be gone for a week -- one final message:
> 
> > > stevan apter <sa <at> nsl.com> wrote:
> > > Heh, yup. No suprise that Chuck would have used one -- engineers are
> > > always using circular buffers. (schtuffers?)
> 
> > so >r and r> rotate the stack left and right one position?  a nice
> > way to store/retrieve things.  (i'm almost kidding - i wouldn't expect
> > moore to do this .. but i would!)
> 
> 'drop' rotates the stack one element, of course... I don't know
> whether there's a word to rotate it the other way.
> 
> > > > > I just thought of a gentler counterexample: a primitive named 'empty?'
> > > > > could be used to implement 'stack'. It returns true when the stack is
> > > > > empty, false otherwise. Its valence is undetectably close to zero,
> > > > > because it doesn't actually consume anything; its charge is a constant
> > > > > 1. (It's not as good of a counterexample as my previous one, because
> > > > > it may be argued that its valence is 1 when the stack's full and 0
> > > > > when the stack's empty -- but that would be a pretty subtle argument.)
> 
(Continue reading)

stevan apter | 2 Jul 18:00 2006

[stack] billy's right

i've added 'stack' and 'unstack' primitives to F:

    [0 <at> ] stack
    [1 <at> ] unstack

    1 2 3 stack
  1 2 3 [1 2 3]
    [4 5 6 7]
  1 2 3 [1 2 3] [4 5 6 7]
    unstack
  4 5 6 7

consistent with my goal of mapping all the K verbs onto symbols (and having
enough left over to support the necessary stack operators and combinators),
i took advantage of the fact the atomic case of  <at>  is identical to the 1
element vector case.

here's the relevant discussion from the paper (http://www.nsl.com/k/f/f.htm):

Valence and Charge
The valence of a program is a pair of non-negative integers. The first element of the pair is the
stack-valence. The stack-valence
of a program is the number of elements it takes from the stack. The second element is the queue-valence. The
queue-valence is the
number of elements it takes from the queue.

The quote operator ' is the only primitive having non-zero queue-valence: it expects to find one element on
the queue, which it
enlists and pushes onto the stack. Hence, quote has stack-valence 1.

(Continue reading)

Christopher Diggins | 4 Jul 23:48 2006
Picon

[stack] Adding another Stack to Cat

I'm planning on adding a second stack to the stack-based programming
language Cat so that it can be more directly translated to other languages
(like the MSIL). As a result I'm having to invent a syntax for
type-annotation of a multi-stack language, because later versions of Cat
will support type annotations. I've posted about it at
http://www.artima.com/weblogs/viewpost.jsp?thread=167276 .

I'd appreciate any comments or insights.

Thanks,
Christopher Diggins
http://www.cdiggins.com/cat/

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

------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/concatenative/

<*> To unsubscribe from this group, send an email to:
    concatenative-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
(Continue reading)

stevan apter | 6 Jul 00:05 2006

Re: [stack] Define statements

the solution i've settled on for F says that everything is a 
function from (environment;stack;queue) to (environment;stack;queue).

The environment is an association of names and values.  Assignment
updates the input environment and returns a new environment.

functions are free to do what they want with any component of an
input triple.

i suppose this is implementation-dependent, but keeping the 
environment distinct from the stack, at least conceptually, seems
like a good thing.  the stack is where results go; the environment
is where bindings go.  

----- Original Message ----- 
From: "Christopher Diggins" <cdiggins <at> gmail.com>
To: <concatenative <at> yahoogroups.com>
Sent: Thursday, June 22, 2006 3:24 PM
Subject: Re: [stack] Define statements

> ".. introduces state ... "
> 
> Good point John. Here is a possible (but not completely thought out)
> solution: allow the definition of symbols as special hash-table values on
> the stack. Global functions are defined at the bottom of the stack. Each
> symbol-hash table acts like a local scope.
> 
> 
> [Non-text portions of this message have been removed]
> 
(Continue reading)

Christopher Diggins | 6 Jul 17:48 2006
Picon

Re: [stack] Define statements

Hi Stevan, What you propose is definitely a reasonable solution.

In Cat however I want to be able to incorporate the idea of nested scope and
nested namespaces. In other words, I want to create environments within
environments. This makes it easier for people developing very complex
software, and it makes mappings from other languages more smooth.

A natural way to do this is to say that each function can have its own
bindings (or environment if you prefer) which requires all definitions to be
unambiguous and resolvable at compile-time. So no reassignments.

In pseudo-code:

define f = a [define g = c; g d] e;

- Christopher

On 7/5/06, stevan apter <sa <at> nsl.com> wrote:
>
>    the solution i've settled on for F says that everything is a
> function from (environment;stack;queue) to (environment;stack;queue).
>
> The environment is an association of names and values. Assignment
> updates the input environment and returns a new environment.
>
> functions are free to do what they want with any component of an
> input triple.
>
> i suppose this is implementation-dependent, but keeping the
> environment distinct from the stack, at least conceptually, seems
(Continue reading)

stevan apter | 6 Jul 23:22 2006

Re: [stack] Define statements

hi christopher

so you want to be able to say things like

    f is g h
     where g is i j
            where i is ..
            where j is ..
     where h is ..

where g and h are local to f and i and j are local to g.

a couple of questions:

can g and h see each other?

can i see g?  f?

what kind of scoping rules do you envision?

i realize that this is a well-worn topic in language theory,
although i'm not myself well-acquainted with all the options
or terminology.  i had to work my way (painfully) through
the alternatives before i had something which was flexible
enough to scale to my satisfaction.  here's my description
of the scoping rules for SLACK:

http://nsl.com/k/slack/slack.htm#2.4%20Definitions

and here's a ray-tracer which demonstrates nested scope:
(Continue reading)

Christopher Diggins | 8 Jul 19:13 2006
Picon

[stack] Rewriting recursion in a stack based language

I believe that in a stack based language like Cat or Joy, the compiler can
use macros instead of functions. Whenever a recursive definition is arrived
upon though, it is replaced simply with a goto. I believe this to be more
powerful than a tail-call recursive optimization, since it works whether or
not the recursive call is at the end of the function. I have written more
about it at http://www.artima.com/weblogs/viewpost.jsp?thread=167848 and I
would appreciate hearing your comments. Hopefully I am not stating the
obvious :-)

Christopher Diggins
http://www.cdiggins.com/cat/

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

------------------------ Yahoo! Groups Sponsor --------------------~--> 
See what's inside the new Yahoo! Groups email.
http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/concatenative/

<*> To unsubscribe from this group, send an email to:
    concatenative-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
(Continue reading)


Gmane