Article View: comp.lang.misc
Article #97Re: Modula-3, Fortran, Numbers & Aliens
From: Raul Deluth Miller-Rockwell
Date: Tue, 07 Apr 1992 14:39
Date: Tue, 07 Apr 1992 14:39
98 lines
4617 bytes
4617 bytes
Stephen P Spackman:
This seems rather odd, given that as a programmer, I see my whole
*job* as being writing functions. A language that has everything
BUT a syntax for writing functions, now, is an odd one. (Don't get
me wrong; I understand the difficulty. A good syntax for function
definition is probably the single hardest "surface" feature to get
right. But not even trying? ;-).
There is a syntax for writing functions. How that looks in use is
something that I find hard to generalize.
But wait, doesn't that contradict your previous statement? If the
GLOBAL value is updated, then in what sense is anything ever
"shadowed"? (Or did you mean you do this for read purposes?).
I meant for "shadowed for read purposes".
|I might define an example of this as follows:
|
|example =. (here_is '.') : ''
|. test=. 3
|. test=: 4
|. 'local ' label test
|. 'global ' label 'test':'' 0
|. NB. return an empty result
|
|Then, if I used
| example 0
|The routine would display:
|local 3
|global 4
|
|And, on exit, 'test' would have the value 4
|
|By the way, I'm presuming that the definitions of 'here_is' and
|'label' are not pertinent to this discussion. Also, 'NB.' introduces
|a comment.
I think they are, because I think they're absolutely necessary for
a mere mortal to understand your example. Fortunately, not having
such problems myself, I figured it out ;-). Gross.
Eh? Oops, I didn't document them: 'here_is' refers to a multi-line
quoted text object, where the argument to here_is indicates the
character(s) used to quote those lines. 'label' will display both its
left and right argument on the screen.
'here_is' is not very general -- it's only useful for making script
files prettier. But that's all you really wanted, wasn't it? For the
result to look pretty?
But I think this rather makes the point: it isn't a statically
scoped language in any conventional sense, or "global", being
defined INSIDE the scope of local test, would get the
currently-in-scope value of "test", viz: 3. Of course, in order
order to implement this, you'd have to associate a lexical
environment with evey string - something that you obviously
wouldn't want to do, which is what prompted me to ask the question.
Yeah, I think so? You're right that this aspect of the language has
not been seen before in other languages.
So the situation ACTUALLY is that there are local scopes and there
are global scopes, and the ONLY scope nesting is that a global
definitions are, if not shadowed, visible locally. I don't think
that's either lexical or dynamic, so much as none at all! - if
local scopes NEVER nest, how can you even discuss HOW?
Nested scopes are unnecessary.
Ok, to be fair, *can* you encode the programme (using infix "." for
lambda abstraction)
f = (x . y . x + y)
(the idea being that (f 1) is the increment function and (f _1) is
the decrement function, e.g.) in such a way that the compiler
doesn't get invoked at runtime?
What's wrong with
f =. +
You can use '&' to curry a dyadic verb, for example, use f&1 for
increment, and f&_1 for decrement.
Failing that (because many languages refuse to do that one) what
about the harder to write but easier to implement:
f = ((x , g) . g (y . x + y))
which gets a similar effect with a callback? "," here is the
pairing operator, of course.
I'm not sure I understand this one. So, I hesitate to provide a
"solution".
--
Raul Deluth Miller-Rockwell <rockwell@socrates.umd.edu>
Technical Details
Message-ID:
<ROCKWELL.92Apr7093925@socrates.umd.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!socrates!socrates!rockwellReferences:
<1992Mar15.221628.24491@yrloc.ipsa.reuter.COM> <ks8boqINN8ht@network.ucsd.edu> <ROCKWELL.92Mar31185022@socrates.umd.edu> <1992Apr3.172844.6152@newshost.lanl.gov> <ROCKWELL.92Apr4080945@socrates.umd.edu> <STEPHEN.92Apr4215253@estragon.uchicago.edu> <R <ROCKWELL.92Apr7005432@socrates.umd.edu> <STEPHEN.92Apr7013424@estragon.uchicago.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.misc Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!socrates!socrates!rockwell From: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) Subject: Re: Modula-3, Fortran, Numbers & Aliens In-Reply-To: stephen@estragon.uchicago.edu's message of Tue, 7 Apr 1992 06:34:17 GMT Message-ID: <ROCKWELL.92Apr7093925@socrates.umd.edu> Sender: rockwell@socrates.umd.edu (Raul Deluth Miller-Rockwell) Organization: Traveller References: <1992Mar15.221628.24491@yrloc.ipsa.reuter.COM> <ks8boqINN8ht@network.ucsd.edu> <ROCKWELL.92Mar31185022@socrates.umd.edu> <1992Apr3.172844.6152@newshost.lanl.gov> <ROCKWELL.92Apr4080945@socrates.umd.edu> <STEPHEN.92Apr4215253@estragon.uchicago.edu> <R <ROCKWELL.92Apr7005432@socrates.umd.edu> <STEPHEN.92Apr7013424@estragon.uchicago.edu> Date: Tue, 7 Apr 1992 14:39:25 GMT