Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Avoiding unintentional variable capture
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 50 of 110 - Collapse all  -  Translate all to Translated (View all originals) < Older  Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stig Hemmer  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Stig Hemmer <s...@pvv.ntnu.no>
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture

rur...@xarch.tu-graz.ac.at (Reini Urban) writes:
> Raymond Toy wrote:
> >How would you tell such a compiler that you really do want variable
> >capture?

> glad you asked that: then I would use a function, not a macro.

OK, write a function which allows you write code more or less like
this:

(asetf (second list) (+ it 7))

The first parameter is a _place_, and the the second is an expression
giving the new value for that place, where the the variable IT is
captured to the old value of that place.

This example is from Paul Grahams book "On Lisp", by the way.

Stig Hemmer,
Jack of a Few Trades.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture
* Dorai Sitaram
| Well, all right.  FWIW, I am sorry you had all those harrowing
| experiences with the Scheme community.  What comes across very clearly in
| your response is that you have this antipathy toward the Scheme
| community, if not toward Scheme per se.  Either kind of antipathy is OK.
| I still think it is unfortunate to be enraged or seduced into silly
| untruths because of that.  Fighting fire with fire really works only for
| the Fire Department.  Out here it only adds to that "sociological mess"
| that you feel burned by.

  excuse me, but why should I feel any better about Scheme, now?  you
  attack one of the most knowledgeable persons in _both_ communities for no
  reason at all.  is this _another_ instance of "political correctness"?

  tell you what: I want to write nice, working programs that don't take
  forever and to use as much of the legacy of mankind as possible in the
  process.  that's why I can't stand Scheme, which makes me feel like I
  have been given exquisitely shaped flint stones and a beautifully
  prepared coat made from a bear's hide, and then I have to re-invent
  everything from there, which will neither be exquisite nor beauitiful
  because I don't have 40,000 years to reinvent everything from where
  Scheme left us in anything but rough ways.  since Scheme people tend to
  be extraordinarily proud of their hand-made bear coats and swing flint
  stones like no one has ever seen and then challenge everyone they meet to
  compete with them on such terms, especially Common Lisp people, I also
  find little reason to frequent Scheme communities.  when you arrive with
  your own neanderthal attitude, Dorai, I tend to think that Scheme people
  should be left alone, possibly relocated to a reservation, but let's make
  sure we don't leave any metal ores nearby.  there's no telling what would
  happen if the Scheme community discovered bronze, or god forbid, iron.
  but at least you're _incredibly_ hygienic and elegant, and I, too, admire
  your fine flint stones, as long as I don't have to use them for anything.

#:Erik
--
  it's election time in Norway.  explains everything, doesn't it?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dorai Sitaram  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: d...@bunny.gte.com (Dorai Sitaram)
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture
In article <sfw671jshxw....@world.std.com>,
Kent M Pitman  <pit...@world.std.com> wrote:

>[grievances deleted because they can't be justly summarized]

OK, I guess you don't have an antipathy to the Scheme
community after all. :->

I wasn't asking you to be polite or not to flame.  I
was asking you not to contribute to misunderstandings,
especially since you seem dedicated to removing them.
That's all.

I sense an attempt ("this is one of them", "two sides",
etc., etc.) to locate me in your standard catalog of
obstreperous rants by the Scheme community.  If you are
not, I am grateful.  I have already twice expressed my
dignified sympathy, and I frankly don't know what else
anybody can do when faced with this kind of extended
regurgitation of grief.  

If, on the other hand, you are indeed locating me in
that noisome catalog of yours, at least there is some
comedy value to it.  Nothing in my two articles can or
should be taken as a brief for Scheme in general or
hygienic macro systems in particular.  Indeed, I quite
agree with you that developments in Scheme have made it
seem to some that hygienic macro systems are necessary
when they aren't really.  I am just saying that having
one or two or many namespaces has no valid bearing on
which way one chooses to jump on the hygiene issue.
That, it would appear, is our only disagreement, or
maybe even not -- I am fast losing track of what you're
trying to say because you are getting way too
discursive.

--d


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture
* Reini Urban
| using macros just not to evaluate one of its arguments is lame.
| lambdas are better.

  then why don't you just program in Scheme?  sometimes, I think the Lisp1
  vs Lispn thing really _is_ about doing things one way or one of n ways.

  what I really _don't_ understand is why Scheme freaks need to _prove_
  Kent's points.  it would seem much more rational to work very hard to
  _disprove_ all his claims.

#:Erik
--
  it's election time in Norway.  explains everything, doesn't it?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture

William Deakin <wi...@pindar.com> writes:
> Raymond Toy wrote:

> > How would you tell such a compiler that you really do
> > want variable capture?

> what about (declare (capturable mungo mongo midge))? ;)

This would get my vote (if I thought the compiler had to be told
anything at all; as I've said, I'm not much of a mind that CL needs
hygiene but if it did, this would be a good way to specify thing).

A principle of language design that I endorse generally is that the
number of words you should have to say in order to communicate an
idea to the compiler should usually be about the same as you'd have
to say to someone over the phone or out loud to someone over dinner
in order to unambiguously communicate the same concept.  To the extent
that you have to say materially more, it's often a cue that the
language designers have not done their job very well.

Although it's not a "language" per se, I have to say that the typical
verbiage you have to say to C++ (and most other languages) to get an
"object foothold" in CORBA is a good example of someplace where the
total number of words is hugely more than the number of words that
should be required.  For some reason, little boilerplate pieces of code
like this seem to get turned into templates to be pasted in by programmers
of other language, and reveled in, rather than as so often in Lisp,
turned into macro expansions never to be seen again by humans.  I don't
know why that is, but I often liken it to the trappings of chemical
addiction, where people are said to really get into the whole business
of preparing their fix as much as the actual actual taking of the drug
(whether it be opening the box of cigarettes and tapping it just so and
smelling it and so on, or whatever more elaborate thing for other drugs).
People are just creatures of habit and seem to gravitate toward systems
that provide them with mounds of predictable if drugerous business.

I dunno--maybe fighting the monotony that other systems serves up just
means users spend their life forever unpredictably stressed by new
technologies and maybe and we shouldn't fight it and should just let
them mire themselves in familiar, if monotonous, drudgery.  But for
some reason I always focus on the idea of digging out of those
monotonous activities to find the new monotonous activities that await
once you get used to what's beyond...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture

d...@bunny.gte.com (Dorai Sitaram) writes:
> I wasn't asking you to be polite or not to flame.  I
> was asking you not to contribute to misunderstandings,

If you go back and re-read the conversation, I think you will see I
attacked no one.  It's possible that your gripe is that in fact I did
attack no one since then that person would be morally empowered to
defend him or herself.  However, I was responding only in kind to a
prior message which spoke about a general problem without specifics as
well, and I was doing my best to speak at the level of abstraction
already introduced and in the context already introduced.

Looking over my original message, the only statement I can think of
which I made which might be controversial was this one, which you
chose to respond to by attacking me pesonally rather than by merely
addressing the technical statement I made:

kmp> They are only really unsafe in Scheme, which has no package
kmp> system and only one namespace.

In defense of this remark, my use of the word "unsafe" was merely
following in the same literature that the Scheme community has used
this term in macros.  There is a technical sense in which "unsafe"
means "capable of accidental capture" and that's a true and defensible
claim.  If you want to add additional remarks saying that you have other
experiences, you're welcome to, but don't say I'm contributing to
confusion merely by restating the problem in a way that is faithful
to the original statement of the problem by the community that originally
established the issue.  Further, it is true that Scheme has no package
system--it has a module system.  And it is, like it or not, a common
oversight by people from the Scheme community who are unused to the package
system to say you can't write a macro that will avoid capture problems
when in fact, it's trivial to write a great many macros that will avoid
this if you just have either GENSYM or else MAKE-PACKAGE and INTERN.
So I don't see how I was contributing to a confusion by saying this.

The remainder of my message aws:

kmp> Macros are not generally unsafe in Lisp.

This statement is true and supported by lots of actual practice.
It does not, in my opinion, contribute to any misperception or confusion.

kmp> Lisp has used its simpler macro system with great success and
kmp> very little problem for many years and unintentional variable
kmp> capture doesn't require anything as sophisticated as a special
kmp> defsafemacro.

This statement also seems true to me even in hindsight.

kmp> This is a common misperception about Lisp which people carry
kmp> in from Scheem.

This statement seems true to me.  It is a common misperception.
I wanted, as I often do, to take the incident of this message to
highlight the issue so that people could watch for it and catch it
when they see it rather than let it go by.  I don't see how watching
for something makes for any confusion or misperception.  I have a lot
of rules that say to "watch for something" in my head; that doesn't
mean I take an explicit action upon seeing them--I'm not advocating
dogma here. I'm advocating kicking this out to "conscious thought"
and not working on "autopilot" when statements of this kind are seen.

kmp> People need to understand that problems always exist in a
kmp> context.

It's hard to see how this contributes to a misperception or confusion.

kmp> Moving to a new context requires reevaluating the issues
kmp> in the new circumstances, not just assuming they carry over.

Ditto.

That concludes the entirety of my message which you chose to single out
an request I ""not [...] contribute to misunderstandings" with.  I stand
by my claim that I did not.  And further I stand by my claim that if there
was or ever is a misunderstanding in what I say, the right thing is simply
to address it at the appropriate technical level.  I think I have an
established record of acknolwedging errors and confusions in what I've said,
or even of acknowledging legitimate points of view that I happen not to
agree with.  I see no reason to get personal.

> especially since you seem dedicated to removing them.

I am dedicated to identifying them.  Removing them seems to me like
fixing the "delete bug"--I don't have pointer access to really do it,
so why try?

> That's all.

> I sense an attempt ("this is one of them", "two sides",
> etc., etc.) to locate me in your standard catalog of
> obstreperous rants by the Scheme community.

I did not originally locate you in anything.  The reply was originally
to Reini and the subject of the sentence in question was the idea, not
the community.  I did not attribute the idea to everyone in the community,
I said the origin of the offending idea was the community.  Communities
are large and pluralistic; no idea that is "of them" is "of every
individual within them".  Nevertheless, it can be useful to understand
the reason for a confusion, and since the reason for this particular
confusion (about hygiene) is based in specific technical details of the
things those people do every day (they really do play with single
namespaces and they really do play with lexicality a lot), it seemed
appropriate to mention the context in order to support my real point which
was that context can influence one's perception of reality.  And that is
a point I don't want to detract from in this long discussion of what is
politically right and wrong to say because it hurts someone's feelings
who I never said I wanted to hurt.

> If you are not, I am grateful.

I am not trying to single out you or anyone to feel bad.
I hate it when people do that to me, and I don't do it to others.

> I have already twice expressed my
> dignified sympathy, and I frankly don't know what else
> anybody can do when faced with this kind of extended
> regurgitation of grief.  

I don't expect more of you.  These remarks on my part are simply
to make sure my point is clear on the record since you have in spite
of your staements of sympathy also herein included additional remarks
about me which I felt required a reply.  This will be my last detailed
statement on the social nature of this since I've pretty much established
my position on my original remarks, and since I don't plan to play
Zeno's Paradox with you, dissecting this conversation into infinity.

> If, on the other hand, you are indeed locating me in
> that noisome catalog of yours, at least there is some
> comedy value to it.  Nothing in my two articles can or
> should be taken as a brief for Scheme in general or
> hygienic macro systems in particular.

Nor should anything in my "articles" be taken to say there is anything
wrong with Scheme having those.  For reasons probably personal to me,
and perhaps not general to others, I personally find the Scheme macro
system painful and ugly, and I never myself use it.  But I know others
that do use it, and I certainly use macros others have written, and
I'm sure that as a matter of technical workmanship and design it's a
fine thing.  (My personal quibbles with it are philosophical, not practical.)
I assume someone must like it because it's there.  I'd have gone for
syntactic closures, myself, in the context of Scheme.  And I'm happy
to do my macro programming in CL where the issue just doesn't arise...

> Indeed, I quite
> agree with you that developments in Scheme have made it
> seem to some that hygienic macro systems are necessary
> when they aren't really.  I am just saying that having
> one or two or many namespaces has no valid bearing on
> which way one chooses to jump on the hygiene issue.

I think this isn't so, but recognize the right of others to disagree
on this as a technical matter.  I base my belief in part on the
technical matter of Lisp1 and in part on the nearly-consequential
sociology that emerges from the technical choice.  As a matter of
observed sociology, I think it does matter.  Science does not
recognize "my hunches" or "my gut feelings based on personal societal
observation" as a proper scientific method of analyzing data per se,
so I forgive you for disagreeing.  But on the other hand, Science does
not say that everything it rejects on the basis of lack of evidence is
false, so please forgive me for believing that the namespace issue
matters even though you don't think so.

I have written a long post on this a long time ago, and you may be
able to find it on deja news. I promised Erik a long time ago that I
would write this up as a real article that I could reference but never
have done so.  I'll keep trying to find the time.  But it's not that
I've never spoken in detail on it.  I just picked a bad forum.
(please no residual converation about my having called comp.lang.lisp
a "bad forum" :-)

> That, it would appear, is our only disagreement, or
> maybe even not -- I am fast losing track of what you're
> trying to say because you are getting way too
> discursive.

Thank goodness it is only me.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dorai Sitaram  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: d...@bunny.gte.com (Dorai Sitaram)
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture
In article <3145964695296...@naggum.no>, Erik Naggum  <e...@naggum.no> wrote:

I have no problem with this kind of characterization of
Scheme.  Scheme is indeed unusable for many, nay, most
purposes.  As I said earlier, my response to Kent is
not a defense of Scheme or the Scheme community at all.
Heck, it is not even a defense of hygienic macro
systems.

Something very strange is going on in this thread.

--d


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture

* Reini Urban wrote:
> glad you asked that: then I would use a function, not a macro.
> functions should have distinctive variables.
> macros just placeholders, they should not infect others.
> (100% unintentional)
> using macros just not to evaluate one of its arguments is lame.
> lambdas are better.

Presumably you'd weaken this in the case where the name came from the
user, or you rule out most of the WITH-x macros (and, in a slightly
alternative universe, you rule out LET too...).

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Howard R. Stearns  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: "Howard R. Stearns" <how...@elwood.com>
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture
Taking a naming cue from Harlequin in an attempt at consensus building,
Eclipse calls this WITH-UNIQUE-NAMES. (Note that
with-unqique-names/with-gensyms is a little different than William's
hygenic-let example.)

Anyway, if you find WITH-UNIQUE-NAMES useful (as I do every day) then
you will also find REBINDING useful, too.  (REBINDING serves the same
purpose as what is called ONCE-ONLY in some implementations.) The doc
for both is at http://www.elwood.com/eclipse/rebinding.htm and
http://www.elwood.com/eclipse/unique.htm

Here's a definition for both.  (I'm with Erik on the issue of having
macro-generated symbols use the names provided by the programmer.  You
can disagree and use GENSYM if you like.)  

A smile-and-a-handshake to anyone who can lucidly explain (no pun
intended) WHY the REBINDING code works, or conversely, convince me that
it doesn't.

(defmacro WITH-UNIQUE-NAMES (vars &body body)
  `(let ,(loop for var in vars
               collect `(,var ,(copy-symbol var)))
     ,@body))

(defmacro REBINDING (vars &body body)       ;difficult code here!..
  (loop for var in vars
        for name = (copy-symbol var)
        collect `(,name ,var) into renames
        collect ``(,,var ,,name) into temps
        finally (return `(let ,renames
                           (with-unique-names ,vars
                             `(let (,,@temps)
                                ,,@body))))))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Tanksley  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: wtank...@dolphin.openprojects.net (William Tanksley)
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture

On Fri, 10 Sep 1999 13:33:26 GMT, Reini Urban wrote:
>Raymond Toy wrote:
>>If your compiler is smart enough to know when NOT to gensym something,
>>then surely it would be smart enough not to waste resources and
>>performance when you DO gensym everything.
>>How would you tell such a compiler that you really do want variable
>>capture?
>glad you asked that: then I would use a function, not a macro.
>functions should have distinctive variables.
>macros just placeholders, they should not infect others.
>(100% unintentional)

I don't see how a function would be able to 'infect others'.  As far as I
can see, only special forms and macros can do that.

Other than that, though, I would have designed the macro system as
hygenic, but with provision for anaphora.  Perhaps this would make it
non-Lisp; if so, we can all be thankful that I am doing no such thing, nor
will I.

>using macros just not to evaluate one of its arguments is lame.
>lambdas are better.

You mean for lazy evaluation?  That doesn't have anything to do with
symbol capture or anaphora.

Macros lack some of the characteristics of functions in Lisp.  It might be
interesting to design a variant in which they had some of those
properties.  I can already see how to design such a variant of Forth,
although it would require a better memory management system than Forth
currently has (it would also be very unForthlike).

I'm not going to even think about it, though -- reading On Lisp has given
me a lot better feel for Lisp, but I'm not that much in touch yet with
what makes Lisp Lisplike :).

>Reini Urban

--
-William "Billy" Tanksley

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Tanksley  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: wtank...@dolphin.openprojects.net (William Tanksley)
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture

On Fri, 10 Sep 1999 17:03:25 GMT, Kent M Pitman wrote:
>d...@bunny.gte.com (Dorai Sitaram) writes:
>> I wasn't asking you to be polite or not to flame.  I
>> was asking you not to contribute to misunderstandings,
>If you go back and re-read the conversation, I think you will see I
>attacked no one.

I don't see him as claiming that -- a flame usually doesn't contribute to
misunderstandings, but rather causes altogether too much understanding. :(

>It's possible that your gripe is that in fact I did
>attack no one since then that person would be morally empowered to
>defend him or herself.  However, I was responding only in kind to a
>prior message which spoke about a general problem without specifics as
>well, and I was doing my best to speak at the level of abstraction
>already introduced and in the context already introduced.

I found your post interesting, since I had taken a contrary position; at
the same time, I don't believe that you established your point, especially
since rather than proving that the problem doesn't affect Lisp or can't be
considered as a problem, you merely stated that as truth and then
attempted to impugn Scheme as having other problems.

>Looking over my original message, the only statement I can think of
>which I made which might be controversial was this one, which you
>chose to respond to by attacking me pesonally rather than by merely
>addressing the technical statement I made:
>kmp> They are only really unsafe in Scheme, which has no package
>kmp> system and only one namespace.
>In defense of this remark, my use of the word "unsafe" was merely
>following in the same literature that the Scheme community has used
>this term in macros.  There is a technical sense in which "unsafe"
>means "capable of accidental capture" and that's a true and defensible
>claim.

This would be entirely true if Scheme's macro system were unhygenic -- but
it isn't.  Its hygene is an essential part of its construction, more so
than Lisp's package system is part of its macro system (if I may make the
ridiculous comparison).

>If you want to add additional remarks saying that you have other
>experiences, you're welcome to, but don't say I'm contributing to
>confusion merely by restating the problem in a way that is faithful
>to the original statement of the problem by the community that originally
>established the issue.  Further, it is true that Scheme has no package
>system--it has a module system.  And it is, like it or not, a common
>oversight by people from the Scheme community who are unused to the package
>system to say you can't write a macro that will avoid capture problems
>when in fact, it's trivial to write a great many macros that will avoid
>this if you just have either GENSYM or else MAKE-PACKAGE and INTERN.
>So I don't see how I was contributing to a confusion by saying this.

It's ridiculous, obviously, to claim that it's impossible to write a safe
macro in Lisp.  GENSYM makes it all possible.  The "problem" is that a
safe macro is a very complicated macro.  My ideal would have safety be the
default, and anaphora require a brief workaround (certainly nothing
complicated).

However, this is somewhat of an aesthetic judgement, and after spending
some time with Scheme, I have to agree that aesthetics are not the best
judge of language power.

>The remainder of my message aws:
>kmp> Macros are not generally unsafe in Lisp.
>This statement is true and supported by lots of actual practice.
>It does not, in my opinion, contribute to any misperception or confusion.

It's true in the sense that macros can _always_ specifically be made safe
in Lisp.

>kmp> Lisp has used its simpler macro system with great success and
>kmp> very little problem for many years and unintentional variable
>kmp> capture doesn't require anything as sophisticated as a special
>kmp> defsafemacro.
>This statement also seems true to me even in hindsight.

I have a problem with it.  Please help me correct my problem.

You say that Lisp's macro system is "simpler".  Presumably you mean
simpler than Scheme's, or perhaps simpler than defsafemacro.  Yet it seems
to me that in order to make safe macros in Lisp, you have to be immensely
more careful and knowledgable about some huge complexities than you have
to be in Scheme.

>kmp> This is a common misperception about Lisp which people carry
>kmp> in from Scheem.
>This statement seems true to me.

It certainly seems accurate to me -- I came in from Scheme, and I have
that perception.  I'd still like to know why it's wrong, although I
certainly don't insist on it.  I'll be spending plenty of time with Lisp
-- it's a better language than Scheme, no doubt.

>It is a common misperception.

I'd _love_ to hear why it's false.  I hear you describing how Scheme would
be dangerous without hygenic macros, and I believe it.  I read "On Lisp"'s
discussion of how Lisp is dangerous without careful attention to every
symbol, and I believe that.  Hygenic macros cause me no effort and don't
add to my code's visual complexity; watching and guarding every symbol
does.

Note that I'm not contradicting you, merely describing my own feelings
about my experiences.

>kmp> People need to understand that problems always exist in a
>kmp> context.
>It's hard to see how this contributes to a misperception or confusion.
>kmp> Moving to a new context requires reevaluating the issues
>kmp> in the new circumstances, not just assuming they carry over.
>Ditto.

It's clear that I need some help in doing that reevaluation.  If I don't
get it, I'll still stick with Lisp, so no pressure.

>That concludes the entirety of my message which you chose to single out
>an request I ""not [...] contribute to misunderstandings" with.  I stand
>by my claim that I did not.  And further I stand by my claim that if there
>was or ever is a misunderstanding in what I say, the right thing is simply
>to address it at the appropriate technical level.  I think I have an
>established record of acknolwedging errors and confusions in what I've said,
>or even of acknowledging legitimate points of view that I happen not to
>agree with.  I see no reason to get personal.

Again, I think his offence was mainly to your attacks against Scheme,
which were made as though Scheme didn't have a hygenic macro system.

You may not have contributed to misunderstandings (although I'd say that
calling Scheme's macro system hazardous is a misunderstanding).  You
certainly, however, did nothing to remove any of those misunderstandings
-- you merely called them out as such.

I can see how that would be insulting to many people who held those
misunderstandings as though they were facts -- a discussion of why their
opinion was a misunderstanding would be interesting, but simply calling it
a misunderstanding isn't.

Is there a web page on this?  Or does "On Lisp" have something about it?

--
-William "Billy" Tanksley


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gareth McCaughan  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Gareth McCaughan <Gareth.McCaug...@pobox.com>
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture

Kent M Pitman wrote:
>                         The thing that I value the most about CL and
> its community is its ability to embrace multiple concepts and multiple
> ways to think about things;

Well, since R5RS Scheme has had multiple values too, so perhaps
things are getting better in that camp. :-)

--
Gareth McCaughan  Gareth.McCaug...@pobox.com
sig under construction


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Goetter  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: goet...@angrygraycat.com.xyz (Ben Goetter)
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture
In article <sfw1zc6lmw2....@world.std.com>, pit...@world.std.com says...

> kmp> They are only really unsafe in Scheme, which has no package
> kmp> system and only one namespace.

> In defense of this remark, my use of the word "unsafe" was merely
> following in the same literature that the Scheme community has used
> this term in macros.  There is a technical sense in which "unsafe"
> means "capable of accidental capture" and that's a true and defensible
> claim.
> [...]
> The remainder of my message aws:

> kmp> Macros are not generally unsafe in Lisp.

> This statement is true and supported by lots of actual practice.
> It does not, in my opinion, contribute to any misperception or confusion.

I beg your pardon, but using what appears to be two definitions of
"unsafe" contributes to confusion.

Of course a Lisp programmer always uses gensym where appropriate to write
a safe macro; thus also with Scheme, as any environment with defmacro
will also have gensym.  (If the Scheme lacks defmacro, how can it be
unsafe?  Unuseful, maybe, but unsafe?)

So they're either both "unsafe" (with quotes - the "capable of accidental
capture" defn), or they're both "safe enough."

[I know that you're going to to respond "I know, I know - look, I was
hacking on (NOT NIL) when you didn't know a LABELS from a LAMBDA."  This
is about contributing to confusion, not educating Kent.  I am here to
learn from Kent, not educate him.  Obviously.  So enough confusion
already.]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas A. Russ  
View profile  
 More options Sep 10 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: t...@sevak.isi.edu (Thomas A. Russ)
Date: 1999/09/10
Subject: Re: Avoiding unintentional variable capture

Erik Naggum <e...@naggum.no> writes:

> * Johan Kullstam
> | graham called it WITH-GENSYMS

>   I have found COPY-SYMBOL to be superior to GENSYM in that the symbols
>   produced have understandable names, which helps a lot when looking at the
>   expansion and at the produced code.

I'm curious why you find COPY-SYMBOL better than GENSYM with an optional
argument.  It would seem that if you ever have nested macros that use
the same names, it would not be possible to distinguish the names
produced by COPY-SYMBOL, since they would print the same.  At least with
the GENSYMs, you can expect that two instances of #:COUNTER-4569
actually refer to the same variable.

--
Thomas A. Russ,  USC/Information Sciences Institute          t...@isi.edu    


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gareth McCaughan  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Gareth McCaughan <Gareth.McCaug...@pobox.com>
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

Howard R. Stearns wrote:
> (defmacro WITH-UNIQUE-NAMES (vars &body body)
>   `(let ,(loop for var in vars
>           collect `(,var ,(copy-symbol var)))
>      ,@body))

Aren't you missing a "'" before the second "," on the third line?

--
Gareth McCaughan  Gareth.McCaug...@pobox.com
sig under construction


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dobes Vandermeer  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Dobes Vandermeer <do...@mindless.com>
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

Reini Urban wrote:

> Of course I know "On Lisp" and the scheme macros which suffer from the
> Lisp1 decision.

> But reading the Tanksley-Joswig talk, Tanksley complaining about the
> semantic problem with macros, I thought why not writing a compiler which
> can automatically rename such captured vars in a new special form,
> defmacro-alike. something like DEFSAFEMACRO. "On Lisp" could be thrown
> away then :)

I feel like I am missing something important here, so I have to ask:
What is the semantic problem with macros that you are referring to?

Thanks
Dobes


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture
* Ben Goetter
| Of course a Lisp programmer always uses gensym where appropriate to write
| a safe macro; thus also with Scheme, as any environment with defmacro
| will also have gensym.  (If the Scheme lacks defmacro, how can it be
| unsafe?  Unuseful, maybe, but unsafe?)

  as I understand this, Scheme cannot generate symbols on the fly in code
  in the first place, since the language is not defined in terms of sexprs,
  but in terms of a grammar with a lexical analysis phase, and that it
  wouldn't help with _possible_ conflicts, since there is no concept of
  "uninterned symbol" (due to lack of a package concept), they do such
  things with LAMBDA and its "renaming", anyway, which is lexical, and if
  Scheme had had DEFMACRO, it would have been tremendously dangerous, since
  it couldn't possibly be safe in Scheme, lacking all the machinery.

  at key here is understanding the Scheme community's attitude towards
  DEFMACRO in Common Lisp.  simply put: they don't understand it, because
  they lack the concepts to deal with what which makes macros safe in CL.
  lack of concepts usually leads to an incredible amount of confusion, but
  the Scheme community has voluntarily rejected a number of concepts, which
  for a number of reasons they can't go back on, and having to do so would
  in turn cause massive upheaval.  thus the emotional intensity.  Scheme
  has reached its evolutionary apex, and anything you can do from here on
  will be perceived to reduce the language.  this is OK by me, actually,
  since I think Scheme is hurting the Lisp community every time a Scheming
  bastard tries to pass Scheme off as "Lisp" sans qualifications.

#:Erik
--
  it's election time in Norway.  explains everything, doesn't it?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reini Urban  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: rur...@xarch.tu-graz.ac.at (Reini Urban)
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

>> That's why I thought it should be done automatically. hmm... Not easy for
>> dynamic lisps like elisp or autolisp.
William wrote:
>Yup. But does that make CL wrong?

not wrong, only worse than it could have been.

>Maybe elisp or autolisp should be lexically scoped. Join the 90's &c :)

that's a different story. <sigh>
it's hard to maintain backwards compatibility with millions's of
"dynamically scoped" (i know, this is a wrong term) legacy code.
with new keywords no problem. but scope is not the problem. well, in my
case it makes things worse because ALL possible candidates may "infect"
the var (placeholder) in the macro, not just the lexically visible.

>> Looks like that I have to patch a CCL copy just for fun, to see if it
>> makes sense to me.

>What is a CCL?

Corman Common Lisp

>> (my local newsfeed is a mess nowadays.  10-20 hours for this...
>Bad news :(

I complained and the news admin rebooted the machine. It seems to be
much better now. Sometimes and in certain fields complaining DOES make
sense :)

--
Reini             _NSAKEY ist mir schon gar nicht mehr wurscht.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reini Urban  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: rur...@xarch.tu-graz.ac.at (Reini Urban)
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

Reini Urban wrote:
>> But reading the Tanksley-Joswig talk, Tanksley complaining about the
>> semantic problem with macros, I thought why not writing a compiler which
>> can automatically rename such captured vars in a new special form,
>> defmacro-alike. something like DEFSAFEMACRO. "On Lisp" could be thrown
>> away then :)
Dobes Vandermeer wrote:
>I feel like I am missing something important here, so I have to ask:
>What is the semantic problem with macros that you are referring to?

that macros are quite unreadable and maintainable.
take a look at "On Lisp" or the typical macros.
and compare this to scheme macros or with-gensym approaches. the rest of
my complain was only about efficiency. how to improve with-gensym, not
to gensym every var, only those which are needed.

secondly, I do care about newbie's (the AutoLISP crowd) who should be
able to understand a macro system (easy) and write correct code then
(hard).
semantics are very important for newbies.

another story with semantics is nested backquoting.
but better have the ` than doing it explicitly.
I know this. I don't even have ` and , not macros in AutoLISP, so I have
to write the expansion explicitly (once) and have to read this mess
(every day).
` comes best to what one could expect for a decent language.
--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reini Urban  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: rur...@xarch.tu-graz.ac.at (Reini Urban)
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

With my compiler (Visual Lisp) I see the difference, because it has to
deal with a dynamic lisp (all vars are global!), and cannot "localize"
(stack-allocate) somewhere globally used vars. (not only those in
lexical context). The performance lost is measurable and annoying in my
libraries.

Gensym'ing all those candidates is slow because gensym is the same hack
as in elisp, interning concatenated strings explicitly, in the global
enviroment.
The compiler is not slow but the resulting code. With proper compiler
analysis it can be improved dramatically in my case.

If it would matter in a decent common lisp implementation I may doubt as
well. Gensym should be fast enough there. esp. because it is only
created in lexical context, so stack-allocated.

sorry for bothering you guys with the better tools.
--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reini Urban  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: rur...@xarch.tu-graz.ac.at (Reini Urban)
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

Stig Hemmer wrote:
>OK, write a function which allows you write code more or less like
>this:

>(asetf (second list) (+ it 7))

please not THIS. "Where comes this 'it' from?" a newbie would ask.
no magic names please. perl already has too much. this makes lisp way
too perl'ish.

and it fails in nested A... constructs as someone from the westcoast
(barry, peter ?) complained last month. ACOND, AIF, AWHILE and such.

it is not the right thing for language design, but it is the right thing
for user code. well, it helps a lot.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Reini Urban  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: rur...@xarch.tu-graz.ac.at (Reini Urban)
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

Erik Naggum wrote:
>* Reini Urban
>| using macros just not to evaluate one of its arguments is lame.
>| lambdas are better.

>  then why don't you just program in Scheme?  sometimes, I think the Lisp1
>  vs Lispn thing really _is_ about doing things one way or one of n ways.

this has nothing to do with multiple or singular namespaces.

>  what I really _don't_ understand is why Scheme freaks need to _prove_
>  Kent's points.  it would seem much more rational to work very hard to
>  _disprove_ all his claims.

i'm no scheme freak at all. i prefer lisp by far.
  (besides demanding tail-call-elimination, but practice is different)
i'm with kent. his claims are rational and politically correct.

my purpose was not to attack common lisp. only to ask how to improve
macro semantics and performance (which are an unsolvable problem and a
non-existing problem, i know).
--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "LET (was Avoiding unintentional variable capture)" by Reini Urban
Reini Urban  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: rur...@xarch.tu-graz.ac.at (Reini Urban)
Date: 1999/09/11
Subject: LET (was Avoiding unintentional variable capture)

Tim Bradshaw wrote:
>(and, in a slightly alternative universe, you rule out LET too...).

You know, I've always had a bad feeling about LET too :)

I cannot create bindings just for debugging purposes by marking the
binding form with the mouse and evaluate it. With the let syntax this is
impossible. With &aux and following setq's it is possible.

and here you caught me again: (sorry, if someone caught me wrong before.
this is nothing against lisp, only another newbie question)

let* and efficiency
i really don't know if the expansion of LET* (into to nested lambdas) is
a good thing or if it should be a special form instead, which can bind
in sequence internally without having to call nested lambdas. lambda
might have some overhead which is not needed in the context of LET*. (?)
but I might be wrong. binding in sequence might require a full LAMBDA to
be correct.
(I don't have SICP or WINSTON/HORN here in the office to prove it by
myself, so I have to sleep over it)
--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Avoiding unintentional variable capture" by Iver Odin Kvello
Iver Odin Kvello  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Iver Odin Kvello <iv...@hfstud.uio.no>
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

>>>>> "EN" == Erik Naggum <e...@naggum.no> writes:

    EN> lexical, and if Scheme had had DEFMACRO, it would have been
    EN> tremendously dangerous, since it couldn't possibly be safe in
    EN> Scheme, lacking all the machinery.

Gambit Scheme has no hygienic macro system built-in; it does however
have a DEFMACRO-like system with gensym and all the necessary
machinery. This is essentially no more a problem[1] than it is in CL (and in
my opinion, this means not a problem at all.).

Also, in the R5RS under 6.3.3, Symbols: "Some implementations have
'uninterned symbols' ...".[2]

The 'problem of unintentional capture' still remains if you accept, as
some must have done, that the possibility of this is a problem in and
of itself, of course, and given that DEFINE-MACRO (which is the
DEFMACRO-in-scheme) fails to solve this problem, then it is unsafe in
the technical sense mentioned. It's pretty clear that this is the
unsafety (is that a word?) deemed problematic, and not just inside of
Scheme, I think, whether or not it was seen to be more problematic
there.  Then again, there are other (technical, percieved) problems
solved by the Scheme systems, and having programs be other than
s-expressions is one of them[3] - useful for doing Dylan at least... I
probably need some emoticon here to avoid being roasted. "%/&.
Oops. Well, anyway.

The program-as-text thing of the RnRS is pretty strange though; I've
never seen any real argument of why it's supposed to be a good idea[4]. It
does of course complicate the whole concept of macros, but what really
puzzles me is eval, 6.5.5: "/Expression/ must be a valid Scheme
expression represented as data, ..." Hm.

Personally, I really like real, DEFMACRO-style macros, with programs
represented as sexps and with the full language available for
transforming them. It's much simpler to explain and understand and to
*implement* for one thing - hygienic macros have been around for a
long time, but people haven't really rushed to implement them in any
kind of lisp. DEFMACRO obviously isn't a safe-syntactic-abstraction-Right
-Thing all by itself, but it seems pretty Right-Thingish anyway, given
what it can do.

Footnotes:
[1]  There are obviously more ways in CL than in Gambit for avoiding
name conflicts, but the ones present in Gambit are sufficient, given
care. I accept that CL would require less care, or tolerate more
carelessness.

[2] With 'uninterned' quoted, and no explaination of what interning a
symbol might mean. It guess it really helps to understand Lisp if one
wants to understand Scheme.

[3]  The other ones I've found mentioned has been a more restricted
form of transformations (especially not allowing side-effects) and
making macros easier to write and/or read, meaning macro-by-example.
I've found these last two desiderata really, *really* frustrating when
trying to use the recently standardized system for anything a bit
complicated. Macro-by-a-really-big-lot-of-examples-with-some-bits-
missing-and-a-nifty-trick-involving-the-string-"snork".

[4]  I've read H.Bakers paper about why it is a really bad idea, though
(Critique of DIN Kernel Lisp) and that seemed pretty much like the
last word on the case for me. So perhaps I just didn't get it.

--
(define (cthulhu_fhthagn)           ;   Iver Odin Kvello, iv...@hfstud.uio.no
   (call/cthulhu  (lambda (destroy) ;        Lambda, the Ultimate Horror
      (if (stars-are-right? (now)) (destroy 'everything) (cthulhu_fhtagn)))))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Sep 11 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: 1999/09/11
Subject: Re: Avoiding unintentional variable capture

rur...@xarch.tu-graz.ac.at (Reini Urban) writes:
> my purpose was not to attack common lisp. only to ask how to improve
> macro semantics and performance (which are an unsolvable problem and a
> non-existing problem, i know).

There is nothing wrong with macro semantics in CL.  What is there is
sound, it just works by different principles than does the Scheme
mechanism.  Principles that are appropriate and natural to the CL
context, where people are pervasively used to implementing separation
of modularity using difference in symbol names by packages.

The reason I object to the use of the phrase "improve macro semantics"
is that it implies an incremental refinement to the CL mechanism,
which would not "improve" the semantics.  An incremental refinement
would add a layer atop what is there but would not change what there
is, and so would be no more nor less semantically strong than what was
there because it would not change its degree of semantic goodness.

It sounds to me like you mean either "change macro semantics" which would
improve some things while breaking everything else (and CL relies to a huge
extent on macros in very fine detail) or else what you are asking for is
a "syntactic", not "semantic", change.

In the former case, you are violating an explicitly stated principle of
the language design, which is stability and a focus on tried-and-true
and well-accepted techniques [and I shouldn't have to say this, but that
has to mean "tried WITHIN the context of CL" not "tried for some other
community"--saying that Scheme-style macros have been "tried" would be
disingenuous and in violation of accepted scientific method.  No controlled
experiment has been tried rewriting substantial large-scale systems that
are heavily based on CL-style macros to see if they could as easily be
written using the Scheme macro system, for example, nor have communities
been given the option of both systems in a test environment to see which
they flock to].

In the latter case of my two from above, where the problem is merely
one of "syntactic sugar" on the existing macro system semantics, which
I'm assuming it more likely what you mean even though you're calling
it "improving macro semantics", the existing macro system, with its
present syntax and semantics, is capable of accomodating a syntax-only
change without any underlying change to what others are doing, just by
getting your own package and defining an appropriate macro that people
can use or not use as they like.  Which if you do will also prove my
point that there was nothing semantically wrong with the existing
macro system.  

I'm really not big on the whole "semantics" thing as a field of
study--to me, the definition of semantics is "means something
intelligible that I can write a compiler for"; I just can't read and
have little use for all that icky math at the back of the Scheme spec.
I'm happy that it's fun for someone, but it does nothing for me.  So I
may be the wrong person to opine on this.  But my seat-of-the-pants
understanding of semantics says that you're only "improving the
semantics" when you are "changing the semantics" + "the change is
positive".  In this case, we can deftly duck the question of whether
the change is positive by observing that absent a request to change
how the language functions, and following up only on the addition of
an extra macro, you are still "compiling the code the same way" (my
definition of "having the same semantics") and consequently you are
not "improving the semantics" becuase you haven't changed it.
Perhaps that just means I'm a backwoods hick who's talking over his
head on a topic he shouldn't be opining about though... always a
possibility.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 26 - 50 of 110 < Older  Newer >
« Back to Discussions « Newer topic     Older topic »