Re: [stack] array theory question

John Nowak <[email protected]>
Newsgroups gmane.comp.lang.concatenative
Message-ID <[email protected]>
On Dec 22, 2008, at 8:56 PM, John Cowan wrote:

> John Nowak scripsit:
>
>> What I'm hoping might make sense here is making the atom 'y'
>> equivalent to '{y}'. This would allow the second form of '&' shown
>> above to be used in the general case. Do you think that may be
>> workable? Is it comparable to what Nial or APL do?
>
> Ah^2.  What you want is Algol 68's "rowing coercion" ("row" being A68
> jargon for vector, or 1-D array).  This coercion transforms a non-row
> value into the corresponding row value with one element.

Very interesting! I suppose the question I'd need to answer is if it's  
sufficient to only go from scalar -> vector. I think the answer is  
"no" if functions like 'square' are meant to operate on vectors rather  
than scalars as then 'square 5' would return a one element vector and  
I'd be back to the same problem regarding construction. It would be  
sufficient however for functions like 'sum' that always return a  
scalar but can consume either a scalar or vector as input. For things  
like 'square', there's always map.

The choices I make here are going to end up depending on the  
complexity of the necessary type system more than anything else. It's  
quite likely that I won't be able to offer a map-like operation that  
works on the vector passed to a function. This is essentially the same  
state of things in a language like Factor where there's no way of  
applying a function to every element of the stack (without using with- 
datastack and then replacing the main stack or something awful).  
Instead, you have stack and arrays as separate concepts. If I go this  
route, the rowing coercion will be sufficient. The only place I think  
I really need to use it is for partial application anyway. It seems a  
shame though to need to add this notion to the type system just for  
this one case, although perhaps there's a nice way of working it into  
the notation so it seems obvious.

Thanks again.

- John
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.