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
Simple newbie list processing troubble
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 - 36 of 36 - Collapse all  -  Translate all to Translated (View all originals) < Older 
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
 
Edi Weitz  
View profile  
 More options Oct 2 2002, 7:11 am
Newsgroups: comp.lang.lisp
From: Edi Weitz <e...@agharta.de>
Date: 02 Oct 2002 13:07:05 +0200
Local: Wed, Oct 2 2002 7:07 am
Subject: Re: Simple newbie list processing troubble
a...@cawtech.freeserve.co.uk (Alan S. Crowe) writes:

X is globally special because you used DEFVAR. Therefore your LET
binds the dynamic variable X to a new value during the execution of
this form.

Consider this:

  (defun foo1 ()
    (declare (special x))
    (let ((x 42))
      (list x (symbol-value 'x))))

  (defun foo2 ()
    (let ((x 42))
      (declare (special x))
      (list x (symbol-value 'x))))

  (defun bar (function)
    (let ((x 'frob))
      (declare (special x))
      (funcall function)))

  * (bar #'foo1)
  (42 FROB)
  * (bar #'foo2)
  (42 42)

Due to your DEFVAR you implicitely used the FOO2 mechanism where I
think you expected FOO1 behaviour.

Look at the entry for LET in the CLHS where it says that "each binding
is lexical unless there is a special declaration to the contrary". So
Erik Naggum was of course right when he said that lexical bindings do
not affect the SYMBOL-VALUE. However, your example wasn't about
lexical bindings.

Edi.


 
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.
Will Deakin  
View profile  
 More options Oct 2 2002, 7:22 am
Newsgroups: comp.lang.lisp
From: Will Deakin <anisotro...@hotmail.com>
Date: Wed, 02 Oct 2002 12:27:40 +0100
Local: Wed, Oct 2 2002 7:27 am
Subject: Re: Simple newbie list processing troubble
Alan S. Crowe wrote:
> Well my old value of x is still there, so a symbol must have
> multiple "symbol values", even when it is special. This
> needs more investigation.

This sounds to me like an issue with understanding scope and
extent[1]. I found this hard to understand and found that the biggest
help was reading chapter 3 of CLTL2[1] several times. (I also realise
that I am in danger of repeating myself...)

:)w

[1] The online version is available here (and other places):
www.ida.liu.se/imported/cltl/clm/clm.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.
Will Deakin  
View profile  
 More options Oct 2 2002, 7:54 am
Newsgroups: comp.lang.lisp
From: Will Deakin <anisotro...@hotmail.com>
Date: Wed, 02 Oct 2002 12:35:05 +0100
Local: Wed, Oct 2 2002 7:35 am
Subject: Re: Simple newbie list processing troubble
Will Deakin wrote:
> I found this hard to understand and found that the biggest help was
> reading chapter 3 of CLTL2[1] several times.

(...and chapter 5,7 and the index...)

;)w


 
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 Oct 2 2002, 8:35 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@cley.com>
Date: 02 Oct 2002 12:37:07 +0100
Local: Wed, Oct 2 2002 7:37 am
Subject: Re: Simple newbie list processing troubble
* Alan S Crowe wrote:

* (defvar x 137)

> X

* x

> 137

* (let ((x 'dragon))

>     (list
>      x
>      (symbol-value 'x)))

That's not a lexical binding, it's a special binding.  Once you've
done a DEFVAR on something it's special for ever - you can never make
it lexical again.

--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.
Dorai Sitaram  
View profile  
 More options Oct 2 2002, 8:52 am
Newsgroups: comp.lang.lisp
From: d...@goldshoe.gte.com (Dorai Sitaram)
Date: 2 Oct 2002 12:52:28 GMT
Local: Wed, Oct 2 2002 8:52 am
Subject: Re: Simple newbie list processing troubble
In article <andu5q$dgso...@ID-105510.news.dfncis.de>,

Adam Warner <use...@consulting.net.nz> wrote:

>(let ((list (list '(list 'list))))
>  (write (list list))
>  (write '(list list)))

>What would be the robust way of processing this code so that only the
>function name list is changed to newlist? Some of the difficulty in
>parsing this code arises out of the separate namespaces.

I didn't understand your motivation for this example,
but converting the example itself seems a lost cause.
Your only way out is to follow the Paul Graham tack of
scrupulously abstaining from the ability to use the
same symbol as both operator name and non-operator
variable.  Once you do that, of course, you aren't
really exploiting the vaunted freedom of a Lisp2
anymore.  You are writing as a Lisp1er (eg, Schemer)
would, except that, unlike them, you are still saddled
with the funcall/#' machinery even though it
isn't buying you anything in an informational sense.

 
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 Oct 2 2002, 8:57 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 02 Oct 2002 12:57:11 +0000
Local: Wed, Oct 2 2002 8:57 am
Subject: Re: Simple newbie list processing troubble
* Erik Naggum
| Lexical bindings do not affect the symbol-value of a the symbol used.

* Alan S. Crowe
| Well my old value of x is still there, so a symbol must have multiple
| "symbol values", even when it is special. This needs more investigation.

  It is not a lexical binding when it is special.  /THINK/!

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.


 
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.
Vassil Nikolov  
View profile  
 More options Oct 2 2002, 9:31 am
Newsgroups: comp.lang.lisp
From: Vassil Nikolov <vnikolo...@poboxes.com>
Date: 02 Oct 2002 09:31:30 -0400
Local: Wed, Oct 2 2002 9:31 am
Subject: Re: Simple newbie list processing troubble
Frode Vatvedt Fjeld <fro...@cs.uit.no> writes:

> What (defvar <x> ..) does, among other things, is to proclaim <x> to
> be a special variable. One consequence of this is that it will be
> _impossible_ to create a lexical binding for <x>.

And which is also (one of the reasons) why it is (usually) a good idea
to have asterisks around the names of special variables.  (Whether
global or not.)

---Vassil.


 
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 Oct 2 2002, 11:35 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@cley.com>
Date: 02 Oct 2002 16:06:31 +0100
Local: Wed, Oct 2 2002 11:06 am
Subject: Re: Simple newbie list processing troubble

* Dorai Sitaram wrote:
> I didn't understand your motivation for this example,
> but converting the example itself seems a lost cause.

This is obviously false.  Anything which understands the code - such
as a correct code walker - can do this kind of replacement.  One
canonical example of such a program is an interpreter or compiler, and
several Lisp environments have compilers which maintain databases of
where functions (and less commonly, but obviously possibly) variables
are used and provided user access to them.  I think at least one
InterLisp system, for instance, allowed you to specify replacements on
programs, relying on this kind of information (and possibly also
allowing pattern-based substitutions too).

In general, I can't see the reason for changing lexically bound
variable names, since (in a Lisp2) they never really matter - the
exceptions being when you want to unify or split two variables.  Those
exceptions can't really be done mechanically since they obviously
change the program semantics.  Dynamic variables are clearly more
interesting to track (and not surprisingly the various
compiler/database systems do tend to track bindings of & references
too specials).

--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.
Joe Marshall  
View profile  
 More options Oct 2 2002, 12:00 pm
Newsgroups: comp.lang.lisp
From: Joe Marshall <j...@ccs.neu.edu>
Date: 02 Oct 2002 11:50:28 -0400
Local: Wed, Oct 2 2002 11:50 am
Subject: Re: Simple newbie list processing troubble

Tim Bradshaw <t...@cley.com> writes:
> In general, I can't see the reason for changing lexically bound
> variable names...

Avoiding name collisions when inlining.

 
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 Oct 2 2002, 12:35 pm
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@cley.com>
Date: 02 Oct 2002 17:20:14 +0100
Local: Wed, Oct 2 2002 12:20 pm
Subject: Re: Simple newbie list processing troubble

* Joe Marshall wrote:
> Avoiding name collisions when inlining.

Oh, yes that's a very good reason. What I meant was as an editorial
change to source code, not as something done during
compilation/evaluation - sorry not to be clearer...

--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.
Erik Naggum  
View profile  
 More options Oct 2 2002, 7:05 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 02 Oct 2002 23:05:16 +0000
Local: Wed, Oct 2 2002 7:05 pm
Subject: Re: Simple newbie list processing troubble
* Dorai Sitaram
| I didn't understand your motivation for this example,
| but converting the example itself seems a lost cause.

  If so, it would also be impossible to execute.  Is it?

| Your only way out is to follow the Paul Graham tack of scrupulously
| abstaining from the ability to use the same symbol as both operator name
| and non-operator variable.

  I think you should say "my only way out" when that is what you mean.

| You are writing as a Lisp1er (eg, Schemer) would, except that, unlike
| them, you are still saddled with the funcall/#' machinery even though it
| isn't buying you anything in an informational sense.

  I think products and vendors should be judged by the intelligence of
  their marketing.  So Scheme must be the choice of the pretty dumb.

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.


 
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.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »