Re: [stack] function/object ambiguity + quotation alternative
"zallambo" <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
--- In [email protected], William Tanksley <wtanksleyjr@...> wrote: > > Stevan Apter wrote: > > From: "John Nowak" <john@...> > > > What XY does seems even worse though! Here's why: > > > 1. [dup] i == [dup] first i (given, as per your example) > > > 2. [dup] == [dup] first (removing shared 'i' suffix) > >> 3. id == first (removing share '[dup]' prefix) > > > no. dup = [dup] first. > > You're right, but he's also right -- you should always be able to remove > identical suffixes from both sides of the equation, and in this case you > can't do that. > > -Wm > (2) does not follow from (1) and (3) does not follow from (2). In general, you *cannot* remove common prefixes and suffixes. For instance, If you could remove prefixes, then [dup] dup == [dup] [dup] => dup == [dup]. If you could remove suffixes, then 2 [id] i == 1 [inc] i => 2 [id] == 1 [inc]. There's nothing special about concatenative languages in this regard; as long as there are functions that aren't reversible (i.e. are not one-to-one and onto), f(a) = f(b) does not imply a = b. And f(a) = g(a) does not imply f = g. I think John has a point though. We need a way to distinguish between the function 'dup' and the object 'dup'. I suggest putting a single quote in front of objects, like symbols in Scheme. So [dup] i == dup [dup] first == 'dup However, we *don't* need to distinguish the number 42 from the function 42. Pushing the number 42 on the stack is exactly the same as applying the function 42 to the stack. So [42] i == [42] first 42 == '42 Does anyone have another syntax for writing 'dup? I cannot recall seeing any. Justin