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
setq x setf
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 1 - 25 of 31 - Collapse all  -  Translate all to Translated (View all originals)   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
 
glauber  
View profile  
 More options Jun 14 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: glauber <glauber.ribeiroNOglS...@experian.com.invalid>
Date: 2000/06/14
Subject: setq x setf
OK, really stupid novice question of the day...

What's the difference between setq and setf? Both of them seem
to set up variables. For example (using Clisp):

[69]> (setf hello 'world)
WORLD
[70]> (setq foo 'bar)
BAR
[71]> hello
WORLD
[72]> foo
BAR

My current idea is that setq applies to variables only, while
setf can apply to other things such as objects. (???)

Again, apologies for the simplicity of the question. I couldn't
figure it out from the Common Lisp spec, or from CLtL2.

glauber

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!


 
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.
Tunc Simsek  
View profile  
 More options Jun 14 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Tunc Simsek <sim...@robotics.eecs.berkeley.edu>
Date: 2000/06/14
Subject: Re: setq x setf
Setf is more general.  You can setf a setfable function:

(defclass c ()
  ((x :accessor x)))

(setq i (make-instance 'c))
(setf (x i) 1)


 
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.
glauber  
View profile  
 More options Jun 14 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: glauber <glauber.ribeiroNOglS...@experian.com.invalid>
Date: 2000/06/14
Subject: Re: setq x setf
Thanks to all who replied.

Just one more question in this thread:

is it OK then to use setf to set variables too, or is there any
advantage to using setq? (performance, maybe?)

glauber

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!


 
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.
d  
View profile  
 More options Jun 14 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: xenop...@irtnog.org (Xenophon Fenderson the Carbon(d)ated)
Date: 2000/06/14
Subject: Re: setq x setf

>>>>> "glauber" == glauber  <glauber.ribeiroNOglS...@experian.com.invalid> writes:

    glauber> My current idea is that setq applies to variables only,
    glauber> while setf can apply to other things such as
    glauber> objects. (???)

SETF applies to "generalized places".  For instance, a location within
an array (as by the accessor AREF) is a place, so to set it, you use:
    (SETF (AREF array index1 ...) newvalue)

Cf. section 5.1 "Generalized Reference" in the HyperSpec
(http://www.xanalys.com/software_tools/reference/HyperSpec/Body/sec_5-...),
as well as the glossary entries for "generalized reference"
(http://www.xanalys.com/software_tools/reference/HyperSpec/Body/glo_g....)
and "place"
(http://www.xanalys.com/software_tools/reference/HyperSpec/Body/glo_p....)

For symbols, it just so happens that

    (SETF FOO 1)

and

    (SETF (SYMBOL-VALUE 'FOO) 1)

are the same thing, largely because

    FOO

and

    (SYMBOL-VALUE 'FOO)

are the same thing.

(SET (QUOTE FOO) 1) and (SETQ FOO 1) are the same thing; SETQ expands
into the SET function, and SET changes the SYMBOL-VALUE of the symbol.

You should probably also take a look at the examples in function
documentation for SET
(http://www.xanalys.com/software_tools/reference/HyperSpec/Body/fun_se...),
as well as read the macro documentation for SETF
(http://www.xanalys.com/software_tools/reference/HyperSpec/Body/mac_se...).

Hope this helps!

--
"I will never submit to your lustful advances", cried Princess Beatrice, as the
wealthy, powerful, muscular and strikingly handsome Count Bertrand slowly
adjusted his mink gloves, "at least for another half-hour!"
 --Dr. Zinn, from the novel


 
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.
Paul Foley  
View profile  
 More options Jun 14 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Paul Foley <mycr...@actrix.gen.nz>
Date: 2000/06/14
Subject: Re: setq x setf
On 14 Jun 2000 19:41:39 -0400, Xenophon Fenderson the Carbon(d)ated wrote:

> For symbols, it just so happens that
>     (SETF FOO 1)
> and
>     (SETF (SYMBOL-VALUE 'FOO) 1)
> are the same thing, largely because
>     FOO
> and
>     (SYMBOL-VALUE 'FOO)
> are the same thing.
> (SET (QUOTE FOO) 1) and (SETQ FOO 1) are the same thing; SETQ expands
> into the SET function, and SET changes the SYMBOL-VALUE of the symbol.

This is false.  Symbols often (even _usually_) have values that are
not the same as the SYMBOL-VALUE.  Try

 (let ((x 42))
   (symbol-value 'x))

and see whether you get 42 or an "unbound variable" error.  [And if
you do get 42, try again in a real Lisp, instead of in Emacs...]

--
If that makes any sense to you, you have a big problem.
                                    -- C. Durance, Computer Science 234
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))


 
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.
Rainer Joswig  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Rainer Joswig <rainer.jos...@ision.net>
Date: 2000/06/15
Subject: Re: setq x setf
In article <0f106a56.4f744...@usw-ex0102-016.remarq.com>, glauber

<glauber.ribeiroNOglS...@experian.com.invalid> wrote:
> My current idea is that setq applies to variables only, while
> setf can apply to other things such as objects. (???)

SETF applies to "places".

If you want to develop datastructures, you usually need
a way to change parts of the datastructure and
a way to retrieve parts of the datastructure.
So you need a "getter" and a "setter".
Common Lisp tries to unify this view so that
you need only to know the getter - if the getter
forms a so called place, then you can use SETF
to change the content.

Example:

Array
- getter is AREF
  (aref *an-array* index)
- setting is done via SETF
  (setf (aref *an-array* index) new-value)

Objects
- getter for slots is SLOT-VALUE
  (slot-value object 'slot-name)
- setting is done via SETF
  (setf (slot-value object 'slot-name) new-value)

You can also define new SETF methods.

See http://www.xanalys.com/software_tools/reference/HyperSpec/Body/mac_se...

--
Rainer Joswig, BU Partner,
ISION Internet AG, Steinhöft 9, 20459 Hamburg, Germany
Tel: +49 40 3070 2950, Fax: +49 40 3070 2999
Email: mailto:rainer.jos...@ision.net WWW: http://www.ision.net/


 
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.
Rainer Joswig  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Rainer Joswig <rainer.jos...@ision.net>
Date: 2000/06/15
Subject: Re: setq x setf
In article <0e31a7e5.65552...@usw-ex0102-016.remarq.com>, glauber

<glauber.ribeiroNOglS...@experian.com.invalid> wrote:
> Thanks to all who replied.

> Just one more question in this thread:

> is it OK then to use setf to set variables too, or is there any
> advantage to using setq? (performance, maybe?)

It's OK to use SETF. It depends on style:

- use the most specific Lisp facility, this makes
  your intentions clear -> SETQ

- use general mechanisms, this reduces cognitive load, since
  you have to remember less programming constructs  -> SETF

--
Rainer Joswig, BU Partner,
ISION Internet AG, Steinhöft 9, 20459 Hamburg, Germany
Tel: +49 40 3070 2950, Fax: +49 40 3070 2999
Email: mailto:rainer.jos...@ision.net WWW: http://www.ision.net/


 
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.
Barry Margolin  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@genuity.net>
Date: 2000/06/15
Subject: Re: setq x setf
In article <0e31a7e5.65552...@usw-ex0102-016.remarq.com>,

glauber  <glauber.ribeiroNOglS...@experian.com.invalid> wrote:
>Thanks to all who replied.

>Just one more question in this thread:

>is it OK then to use setf to set variables too, or is there any
>advantage to using setq? (performance, maybe?)

SETF is a macro that expands into whatever is appropriate for the
destination.  (setf <var> <value>) will expand into (setq <var> <value>) at
compile time, so the behavior should be identical.

As the other poster said, it's purely a stylistic choice.

--
Barry Margolin, bar...@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


 
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.
Paul Foley  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Paul Foley <mycr...@actrix.gen.nz>
Date: 2000/06/15
Subject: Re: setq x setf
On 14 Jun 2000 19:41:39 -0400, Xenophon Fenderson the Carbon(d)ated wrote:

> For symbols, it just so happens that
>     (SETF FOO 1)
> and
>     (SETF (SYMBOL-VALUE 'FOO) 1)
> are the same thing, largely because
>     FOO
> and
>     (SYMBOL-VALUE 'FOO)
> are the same thing.
> (SET (QUOTE FOO) 1) and (SETQ FOO 1) are the same thing; SETQ expands
> into the SET function, and SET changes the SYMBOL-VALUE of the symbol.

This is false.  Symbols often (even _usually_) have values that are
not the same as the SYMBOL-VALUE.  Try

 (let ((x 42))
   (symbol-value 'x))

and see whether you get 42 or an "unbound variable" error.  [And if
you do get 42, try again in a real Lisp, instead of in Emacs...]

--
If that makes any sense to you, you have a big problem.
                                    -- C. Durance, Computer Science 234
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))


 
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.
Philip Lijnzaad  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Philip Lijnzaad <lijnz...@ebi.ac.uk>
Date: 2000/06/15
Subject: Re: setq x setf

> (SET (QUOTE FOO) 1) and (SETQ FOO 1) are the same thing; SETQ expands
> into the SET function, and SET changes the SYMBOL-VALUE of the symbol.

But SET has been officially deprecated ...

                                                                      Philip
--
Ban GM foods! Long live the Mesolithicum, pesticides and starvation
--------------------------------------------------------------------------- --
Philip Lijnzaad, lijnz...@ebi.ac.uk \ European Bioinformatics Institute,rm A2-24
+44 (0)1223 49 4639                 / Wellcome Trust Genome Campus, Hinxton
+44 (0)1223 49 4468 (fax)           \ Cambridgeshire CB10 1SD,  GREAT BRITAIN
PGP fingerprint: E1 03 BF 80 94 61 B6 FC  50 3D 1F 64 40 75 FB 53


 
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 Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/15
Subject: Re: setq x setf
* glauber <glauber.ribeiroNOglS...@experian.com.invalid>
| What's the difference between setq and setf?

  setq is a special operator that takes a variable (binding, really)
  and a value, and causes references to that variable (binding) after
  the setq to yield the value.

  setf is a macro that takes a place (generalized reference) and a
  value, and causes references to the place after the setf to yield
  the value, in ways appropriate for each place.  It expands into setq
  for variables (bindings), for instance.

#:Erik
--
  If this is not what you expected, please alter your expectations.


 
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 Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/15
Subject: Re: setq x setf
* Xenophon Fenderson the Carbon(d)ated
| For symbols, it just so happens that
|     (SETF FOO 1)
| and
|     (SETF (SYMBOL-VALUE 'FOO) 1)
| are the same thing, largely because
|     FOO
| and
|     (SYMBOL-VALUE 'FOO)
| are the same thing.

  This is just plain false.

| (SET (QUOTE FOO) 1) and (SETQ FOO 1) are the same thing; SETQ expands
| into the SET function, and SET changes the SYMBOL-VALUE of the symbol.

  This is just plain false, too.

#:Erik
--
  If this is not what you expected, please alter your expectations.


 
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 Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@cley.com>
Date: 2000/06/15
Subject: Re: setq x setf

* glauber  wrote:
> is it OK then to use setf to set variables too, or is there any
> advantage to using setq? (performance, maybe?)

I use SETF exclusively.  There should not be any performance
difference -- SETF will macroexpand to SETQ in the simple cases.

--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.
d  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: xenop...@irtnog.org (Xenophon Fenderson the Carbon(d)ated)
Date: 2000/06/15
Subject: Re: setq x setf

>>>>> "Paul" == Paul Foley <mycr...@actrix.gen.nz> writes:

    Paul> This is false.  Symbols often (even _usually_) have values
    Paul> that are not the same as the SYMBOL-VALUE.  Try

    Paul>  (let ((x 42)) (symbol-value 'x))

Yup.  In my zeal to answer I totally forgot about lexical bindings.

--
"I will never submit to your lustful advances", cried Princess Beatrice, as the
wealthy, powerful, muscular and strikingly handsome Count Bertrand slowly
adjusted his mink gloves, "at least for another half-hour!"
 --Dr. Zinn, from the novel


 
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 Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/15
Subject: Re: setq x setf
* Philip Lijnzaad <lijnz...@ebi.ac.uk>
| But SET has been officially deprecated ...

  I think this was a bad idea.  I completely fail to appreciate some
  of the deprecations -- most of them give me this icky Scheme feeling.

  (remove-if-not <obvious-function> ...) is supposed to be inferior to
  (remove-if (complement <obvious-function) ...)?  I'm _so_ thrilled
  with the double negative, already, I really need _complement_!  And
  (set <symbol> <value> is inferior to (setf (symbol-value ...) ...)?
  Gimme a break!

  Deprecation is a signal to the community that it needs to evaluate
  its habits and signal the committee back if it deems them valid.
  For instance, there's no doubt that :test and :test-not had fuzzy
  semantics when combined and non-trivial prophylaxis, but that
  doesn't mean the *-if-not functions suffer similarly fuzziness.

  I use set when I actually have symbols that I don't _want_ to be
  some general data structure.  Symbols are special animals in many
  ways, and I don't want to bury that in a "call" to symbol-value.

#:Erik, ¢2
--
  If this is not what you expected, please alter your expectations.


 
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.
Paul Dietz  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: di...@comm.mot.com (Paul Dietz)
Date: 2000/06/15
Subject: Re: setq x setf
In article <BTV15.98$Nf7.2276@burlma1-snr2>,
Barry Margolin  <bar...@genuity.net> wrote:

> SETF is a macro that expands into whatever is appropriate for the
> destination.  (setf <var> <value>) will expand into (setq <var> <value>) at
> compile time, so the behavior should be identical.

Nitpick: in theory, yes, in practice there can be a trivial but
nonzero difference in some implementations.

For example, if *x* is a global variable then the forms

        (setq *x* t)

and

        (setf *x* t)

compile to different code in ACL 5.0.1 (this is because the SETF macro
inserts a temporary variable in the second case and does not propagate
the T forward in a way that lets the compiler figure out that no write
barrier is needed.)

        Paul


 
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 Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/15
Subject: Re: setq x setf
* Paul Dietz
| Nitpick: in theory, yes, in practice there can be a trivial but
| nonzero difference in some implementations.

  If practice differs from theory, you have found a bug.  Report bugs
  as bugs to be removed, not as some nasty thing programmers need to
  be made _aware_ of.  Sheesh!  Such is the worst of all possible ways
  to deal with problems.  If you don't get a fix within a reasonable
  amount of time and the bug causes you to have to circumvent good
  engineering decisions and write bad code that increases the overall
  complexity of the system and introduces portability and maintenance
  issues that are otherwise unwarranted, complain _vociferously_.
  Accept no substitute for fixes to demonstrable bugs!

  (Well, in this here day and age, one _acceptable_ "substitute" for
  fixes to other people's mistakes is a reduced purchase price of the
  buggy product, such as you getting the source code and assuming full
  responsibilit for any problems.  To some of us, that is unworkable.)

| For example, if *x* is a global variable then the forms (setq *x* t)
| and (setf *x* t) compile to different code in ACL 5.0.1 ...

  I have been unable to reproduce this as stated.

#:Erik
--
  If this is not what you expected, please alter your expectations.


 
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.
Barry Margolin  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@genuity.net>
Date: 2000/06/15
Subject: Re: setq x setf
In article <3170059273480...@naggum.no>, Erik Naggum  <e...@naggum.no> wrote:

>* Philip Lijnzaad <lijnz...@ebi.ac.uk>
>| But SET has been officially deprecated ...

>  I think this was a bad idea.  I completely fail to appreciate some
>  of the deprecations -- most of them give me this icky Scheme feeling.
...
>  I use set when I actually have symbols that I don't _want_ to be
>  some general data structure.  Symbols are special animals in many
>  ways, and I don't want to bury that in a "call" to symbol-value.

SET was deprecated in favor of SETF of SYMBOL-VALUE.  You can still do what
you want to do, we're just encouraging you to use a more "modern" syntax.

I think the feeling was that this isn't such a common thing that we really
need two ways to do it in the language.  30 years ago SETF and DEFSTRUCT
didn't exist, and SET was pretty commonly used, but it's now a relic and
not deserving of such a privileged status.

On the other hand, we didn't deprecate SETQ in favor of SETF because SETQ
is used pervasively.  Making everyone globally replace all their SETQ's
with SETF's would be horrible.

--
Barry Margolin, bar...@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


 
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.
Philip Lijnzaad  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Philip Lijnzaad <lijnz...@ebi.ac.uk>
Date: 2000/06/15
Subject: Re: setq x setf

Erik> * Philip Lijnzaad <lijnz...@ebi.ac.uk>
Erik> | But SET has been officially deprecated ...

Erik>   I think this was a bad idea.  I completely fail to appreciate some
Erik>   of the deprecations -- most of them give me this icky Scheme feeling.

I have no real experience with this, but would find

   (setf (symbol-value sym) val)

much much clearer than

   (set sym val)

The first form signals to me that something not entirely usual is going on;
the latter looks more like a nasty-to-spot typo. Like it's kinda clearer to
see

    (funcall (hi-order-func args) more-args)

than

    ((hi-order-func args) more-args)

, really.

Erik>   Gimme a break!

uh, yes, I was going to: what happened to all your lowercase sentence
beginnings ?-)
                                                                      Philip
--
Ban GM foods! Long live the Mesolithicum, pesticides and starvation
--------------------------------------------------------------------------- --
Philip Lijnzaad, lijnz...@ebi.ac.uk \ European Bioinformatics Institute,rm A2-24
+44 (0)1223 49 4639                 / Wellcome Trust Genome Campus, Hinxton
+44 (0)1223 49 4468 (fax)           \ Cambridgeshire CB10 1SD,  GREAT BRITAIN
PGP fingerprint: E1 03 BF 80 94 61 B6 FC  50 3D 1F 64 40 75 FB 53


 
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.
Sashank Varma  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: sash...@vuse.vanderbilt.edu (Sashank Varma)
Date: 2000/06/15
Subject: Re: setq x setf
In article <0e31a7e5.65552...@usw-ex0102-016.remarq.com>, glauber

<glauber.ribeiroNOglS...@experian.com.invalid> wrote:

[snip]
>is it OK then to use setf to set variables too, or is there any
>advantage to using setq? (performance, maybe?)

[snip]

i use SETQ on the principle that using the most specific construct
best communicates intent.

then again, i use (SETF (CAR ...) ...) and (SETF (CDR ...) ...)
rather than RPLACA and RPLACB, so take my advice with a grain of
salt!

sashank


 
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.
Sashank Varma  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: sash...@vuse.vanderbilt.edu (Sashank Varma)
Date: 2000/06/15
Subject: Re: setq x setf
In article <aT625.10$4p1.258@burlma1-snr2>, Barry Margolin

<bar...@genuity.net> wrote:

[snip]

>SET was deprecated in favor of SETF of SYMBOL-VALUE.  You can still do what
>you want to do, we're just encouraging you to use a more "modern" syntax.

>I think the feeling was that this isn't such a common thing that we really
>need two ways to do it in the language.  30 years ago SETF and DEFSTRUCT
>didn't exist, and SET was pretty commonly used, but it's now a relic and
>not deserving of such a privileged status.

>On the other hand, we didn't deprecate SETQ in favor of SETF because SETQ
>is used pervasively.  Making everyone globally replace all their SETQ's
>with SETF's would be horrible.

since SETF is a macro, it has to expand into an expression.
i assume that implementations ensure that this expansion is
pure ANSI CL; this may even be mandated in the standard.

so, (SETF (SYMBOL-VALUE ...) ...) is probably expanded in
the following way in all implementations:
     ? (macroexpand '(setf (symbol-value '*a*) 5))
     (SET '*A* 5)
      T
     ?
does this imply that SET will never disappear, then, for
if it did, SETF would have no ANSI CL construct to expand to
(i.e., one that modifies dynamic bindings)?

the same logic seems to imply that, the pervasiveness of
SETQ aside, it will never go away because (SETF <symbol> ...)
will always require it for expansion purposes.

is this right?  one way that i could be wrong is that it
could be perfectly legal for SETF to macroexpand into
implementation-specific mechanisms for modifying bindings,
but this just seems wrong.

sashank


 
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.
Barry Margolin  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@genuity.net>
Date: 2000/06/15
Subject: Re: setq x setf
In article <sashank-1506001511560...@129.59.212.53>,

Sashank Varma <sash...@vuse.vanderbilt.edu> wrote:
>does this imply that SET will never disappear, then, for
>if it did, SETF would have no ANSI CL construct to expand to
>(i.e., one that modifies dynamic bindings)?

If SET disappears, it can expand into

(funcall #'(setf set) 5 '*A*)

or

(SYSTEM-INTERNAL::SET-SYMBOL-VALUE '*A* 5)

>is this right?  one way that i could be wrong is that it
>could be perfectly legal for SETF to macroexpand into
>implementation-specific mechanisms for modifying bindings,
>but this just seems wrong.

This is the case.  Consider that there are no standard expressions for SETF
of the following accessors to expand into: GETHASH, DOCUMENTATION,
FILL-POINTER, SYMBOL-FUNCTION, SYMBOL-PLIST, MACRO-FUNCTION.  Historically,
accessors inherited from Maclisp have standard setter function, since
Maclisp didn't have SETF as a built-in feature and the setters were
retained for compatibility (the property list functions are an exception, I
don't know why compatibility for them was dropped), but accessors inherited
from Zetalisp or introduced by the Common Lisp designers do not since
there's no compatibility requirement.

--
Barry Margolin, bar...@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


 
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 Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/15
Subject: Re: setq x setf
* sash...@vuse.vanderbilt.edu (Sashank Varma)
| since SETF is a macro, it has to expand into an expression.
| i assume that implementations ensure that this expansion is
| pure ANSI CL; this may even be mandated in the standard.

  Why do you assume that?  Why should it be mandated?

| one way that i could be wrong is that it could be perfectly legal
| for SETF to macroexpand into implementation-specific mechanisms for
| modifying bindings, but this just seems wrong.

  Could you elaborate on why you think this way?

#:Erik
--
  If this is not what you expected, please alter your expectations.


 
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.
Barry Margolin  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Barry Margolin <bar...@genuity.net>
Date: 2000/06/15
Subject: Re: setq x setf
In article <3170098053699...@naggum.no>, Erik Naggum  <e...@naggum.no> wrote:

>* sash...@vuse.vanderbilt.edu (Sashank Varma)
>| since SETF is a macro, it has to expand into an expression.
>| i assume that implementations ensure that this expansion is
>| pure ANSI CL; this may even be mandated in the standard.

>  Why do you assume that?  Why should it be mandated?

Assumptions don't have reasons.  If they did, they would be conclusions,
not assumptions.

--
Barry Margolin, bar...@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.


 
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.
Steven M. Haflich  
View profile  
 More options Jun 15 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: "Steven M. Haflich" <hafl...@pacbell.net>
Date: 2000/06/15
Subject: Re: setq x setf

Erik Naggum wrote:

> * sash...@vuse.vanderbilt.edu (Sashank Varma)
> | since SETF is a macro, it has to expand into an expression.
> | i assume that implementations ensure that this expansion is
> | pure ANSI CL; this may even be mandated in the standard.

>   Why do you assume that?  Why should it be mandated?

> | one way that i could be wrong is that it could be perfectly legal
> | for SETF to macroexpand into implementation-specific mechanisms for
> | modifying bindings, but this just seems wrong.

It is perfectly legal for setf expansions to use implementation-specific
mechanisms.  Indeed, it is logically necessary in those cases where
there is no specified mechanism in the standard for performing a
specified operation.  For example, as has been pointed out, setf of
fill-pointer _must_ expand into something not specified in the ANS since
the ANS specifies nothing that will do the job.

BUT any such implementation-specific mechanism _must_ be (or eventually
macroexpand into) a call to an implementation function.  No implementation
setf expansion, nor for that matter any other standard macro, may expand
into a nonstandard special form.  To do so would make it impossible for
portable code walkers to work, and that would be a bad thing.

Compilers are free to treat additional operators as special forms, but
they must provide real macro or function versions for benefit of other
code walkers that they themselves may ignore in favor of some semantically
equivalent special form.


 
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 1 - 25 of 31   Newer >
« Back to Discussions « Newer topic     Older topic »