Easier stack operations thanks to typing

26 views
Skip to first unread message

pierre

unread,
Nov 1, 2008, 11:11:27 AM11/1/08
to Cat Language
Hello,

I had though about concatenative typed programming some time ago, and
I was pleased to see my ideas and much more than already beautifully
done in your Cat language.

The only feature I would miss is: to threat the stack according to
value's type, i.e.

A function taking type X would take not the stack's top, but the
highest element with type X.

As far as I could see, this type of behavior is not considered in your
paper (please correct me if I'm wrong). But I find this a very useful
feature, which would mitigate one of Forth's greatest (imho)
weaknesses: 'stack juggling'.

I would like to believe that my small contribution will be useful.

--
pierre

pierre

unread,
Nov 1, 2008, 11:19:13 AM11/1/08
to Cat Language
> The only feature I would miss is: to threat the stack according to

Of course that is treat, please excuse my English :-)

Christopher Diggins

unread,
Nov 1, 2008, 11:25:14 AM11/1/08
to catla...@googlegroups.com
Hi Pierre thanks for writing.
 
That sounds like a nice feature. I don't fully know how to type it. Maybe some kind of wild-card would be needed?
 
define get_top_int : (int 'A:* -> int 'A int)
{ /* looks under N values until it finds an int and copies it to the top */ }

- Christopher

pierre

unread,
Nov 1, 2008, 11:38:20 AM11/1/08
to catla...@googlegroups.com
On Sat, Nov 01, 2008 at 11:25:14AM -0400, Christopher Diggins wrote:
> Hi Pierre thanks for writing.
>
> That sounds like a nice feature. I don't fully know how to type it. Maybe
> some kind of wild-card would be needed?

I thought of it as the only available stack mechanism, and I belive
there could be some optimising technique which could eliminate most of
the slowdown introduced -- especilally in a language with constant
type effects.

In my view, if you stuck to this option you would get this feature for
free leaving others intact.

> define get_top_int : (int 'A:* -> int 'A int)
> { /* looks under N values until it finds an int and copies it to the top */
> }
>
> - Christopher
>

--
pierre

Reply all
Reply to author
Forward
0 new messages