Re: [stack] Re: Cat article submission to Doctor Dobbs Journal

"Christopher Diggins" <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
Hi John,

Thanks a lot for the comments.

On Feb 10, 2008 8:40 PM, John Nowak <[email protected]> wrote:
> I'll be quick here, as I haven't the time I wish I had.

Sorry about that.
> The introduction seems weak. Simplicity doesn't come from a low number
> of concepts.

I'm a little confused: a low number of concepts seems to be the very
definition of simplicity.

> If it did, the SK-calculus would be the language all new
> programmers would be starting with.

You seem to be saying here more that a low number of concepts doesn't
neccessarily make a language appropriate for beginners. Is this
correct? If so I do agree with you. The other reason, which I should
perhaps include is the fact that the model of computation closely
resembles what actually happens in a computer.

> It seems like offering a hook
> beyond how "simple" it is should be part of your introduction.

Fair enough, I'll see if I can do better.

> There
> is the discussion of efficiency, but at least for me, this is one of
> the least interesting parts about Cat.

What do you think is the most interesting part of Cat, if any? And I'm
not just fishing for compliments, honest :-)

>  That said, I'm not sure how I'd
> rework this...
>
> > In the Cat specification instructions are referred to as functions,
> > whether or not they have side-effects.
>
> Do functions actually have side-effects?

In Cat they do (according to my definition of function).

> If all functions are unary
> functions of stacks to stacks, it's easy to thread an implicit world
> state through the entire program.

It's possible, but I wouldn't call it easy. I struggled for a long
time to figure out how to do it in Cat. Then again "easy" is always
relative, I'm sure it was easier for you. :-)

>  I believe Backus's FL did something
> similar. As far as I'm concerned, Cat is purely functional. Functions
> of the type A ~> B are functions that read/write the world state on
> the top of the stack. All other operations work below it.
>
> > Functions can not be redefined, and are only visible after they are
> > defined.
>
> Does this mean recursive definitions are disallowed?

No. I see your point though, it is unclear. Thanks for pointing it out.

> > In Joy parlance this is called a quotation, but I prefer to think of
> > it as either an anonymous function or lambda expression.
>
> Lambda expression might not be the term to use here as there are no
> variables involved.

Good point.

> > A possible definition of bin_rec is shown Figure X.
>
> So bin_rec must be a primitive?

No, why do you ask? I am intending to show that it can be defined in a
library, so it doesn't have to be made a primitive.
I am probably not being clear. The Cat primitive set is somewhat
arbitrary, different implementations would choose different operations
to implement as predefined primitives.

> If so, that should probably be stated.
> I assume that's the case for reasons related to the type system, as I
> believe you can write it in Joy.

Yes you can.

> > For those who like big Greek words
>
> I don't know who the intended audience of this is (I'm not familiar
> with Doctor Dobbs), but I find this level of informality off-putting.

I can understand. I was on the fence here, I was just trying to add a
bit of levity, and to laugh a bit at the tendency of the community to
overuse greek-like words (I am not convinced that those are real
words). DDJ is a trade magazine intended for software development
professionals.

> > Metadata is a form of structured comment that can be associated with
> > a Cat program. I use it to document functions, and provide automatic
> > unit tests.
>
> Again, not sure on the audience, but "I use it" as opposed to "Its
> intended use is" strikes me as odd.
>
> > Static type systems are useful for documentation, static
> > verification of code, and optimization.
>
> And more!

I could use some inspiration here. ;-)
Any suggestions?

> > It is common practice in stack languages to document the stack
> > effects of each instruction, i.e. what type of values are remove
> > from the stack (the consumption), and what type of values are placed
> > on the stack (the production).
>
> That should be 'e.g.', not 'i.e.'.

Why is that? I thought it was more of an elaboration than an example.

> > If the type annotation is omitted, Cat is able to infer the type
> > automatically, using a variant of the Hindley-Milner algorithm [X]
>
> Should be: "If a type annotation is omitted, Cat is able to infer a
> type automatically using a variant of the Hindley-Milner algorithm [X]."

Okay.

> > Using the Cat interpreter "#t" will give you the type of any
> > function on the stack.
>
> I don't quite understand this sentence. Perhaps "Using '#t' in the Cat
> interpreter"?

Yes, thanks.

> > The most important properties are: whether the required input types
> > for a function are being supplied when it is called
>
> Perhaps "values of the correct types" is better.

Yep,

> > A somewhat novel feature of the Cat type system is that all
> > functions are row polymorphic [ref] (also called tail polymorphic)
>
> I don't have time to get into this now, but I think there are cases
> when you don't want functions to be row polymorphic. A trivial
> example: Supplying a function that takes two arguments for use in a
> callback. Simply requiring the function to unify with (A b c -> A)
> would be insufficient, as you'd be allowed to pass something like (A b
> c d e -> A b).

This is interesting, I will have to look at the issue carefully before
I comment on it.

>  I've had to introduce an additional concept to my type
> system to address this. First-class stacks (evaluated on via Joy's
> 'infra') also seem to require this.

I don't support first-class stacks in Cat.

> I'll post in more detail soon I'm
> sure...

I look forward to it.

> > define quadratic { [dupd [sqr] dip swap [*] dip] dipd [* +] dip + }
>
> If you take the arguments in reverse order, as you typically would,
> you can do this:
>
> 2dup [* * swap] dip * + +

That is interesting. Personally I wouldn't typically do that, because
I would like to write things like:

define quad234 { 2 3 4 quadratic }

> > Now we partially evaluate the "papply" functions:
>
> Better than 'curry'. :)

:-)

I can't help but think that maybe "partial curry" would be a more
accurate term, but history wins here.

> Anyway, I hope something in there helped. Sorry I don't have time for
> a more thorough reading.
>
> - John

I really appreciate your comments, thanks a lot!

- Christopher
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.