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
prog@
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 73 - 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
 
Marcus Breiing  
View profile  
 More options Nov 14 2002, 4:07 pm
Newsgroups: comp.lang.lisp
From: Marcus Breiing <news-gwif...@breiing.com>
Date: 14 Nov 2002 22:07:16 +0100
Local: Thurs, Nov 14 2002 4:07 pm
Subject: Re: prog@

Erik Naggum <e...@naggum.no> wrote:
>   If you edit code, anything that keeps all of ASCII from being
>   accessible without contortions is rabidly insane.

Hitting two or even three keys in sequence to get an operator from
your favorite programming language isn't really *rabidly* insane.
Hell, if it were, we'd all have to switch to Paul Graham's Arc, which
seems to be based on that idea:-)

That said, the one place where I actually had to type the caret more
than once in a blue moon was in Gnus, to move up the reference chain.
I changed that keybinding, and that was it.

What isn't good thinking IMHO is for a language *designer* to reject a
syntax that would be really nice just because he can't type it
conveniently using his *current* setup.  That'd be like specifying a
fixed huffman tree for ZIP and expect people to adjust their
compressible material accordingly.

--
Marcus Breiing
mailto:news-gwif...@breiing.com (will expire)


 
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.
Marcus Breiing  
View profile  
 More options Nov 14 2002, 4:15 pm
Newsgroups: comp.lang.lisp
From: Marcus Breiing <news-gwif...@breiing.com>
Date: 14 Nov 2002 22:15:05 +0100
Local: Thurs, Nov 14 2002 4:15 pm
Subject: Re: prog@

Nils Goesche <car...@cartan.de> wrote:
> $ setxkbmap -layout us

Well, I use Win2K as a device driver so that wouldn't work.  However,
on this system I can hit alt-shift to switch between German and US
layout on the fly.  Nifty.

I also do major-mode dependent remapping of ö,ä and ü, but that's
about all the keyboard mangling I can stomach.  I like to retain the
ability to work on other people's computers.  I have almost *lost* the
ability to use non-RPN pocket calculators, and that bothers me,
sometimes:-)

--
Marcus Breiing
mailto:news-gwif...@breiing.com (will expire)


 
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 Nov 14 2002, 4:26 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 14 Nov 2002 21:26:34 +0000
Local: Thurs, Nov 14 2002 4:26 pm
Subject: Re: prog@
* Marcus Breiing
| That'd be like specifying a fixed huffman tree for ZIP and expect people
| to adjust their compressible material accordingly.

  Good analogy.

--
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.
Joe Marshall  
View profile  
 More options Nov 14 2002, 4:30 pm
Newsgroups: comp.lang.lisp
From: Joe Marshall <j...@ccs.neu.edu>
Date: 14 Nov 2002 16:30:53 -0500
Local: Thurs, Nov 14 2002 4:30 pm
Subject: Re: prog@

Erik Naggum <e...@naggum.no> writes:
>   On Norwegian keyboards, {}[] are reachable with AltGr and a digit key on
>   the left hand.  If you write in any language using the C syntax template,
>   and you have /not/ changed to a US keyboard layout to get rid of this
>   monstrous insanity, you deserve the wrists you are soon going to get.

But what about trigrams......?

 
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.
Pascal Costanza  
View profile  
 More options Nov 14 2002, 5:05 pm
Newsgroups: comp.lang.lisp
From: Pascal Costanza <costa...@web.de>
Date: Thu, 14 Nov 2002 23:05:02 +0100
Local: Thurs, Nov 14 2002 5:05 pm
Subject: Re: prog@

Oh dear! ;)

> Hey, when you're done with prog@, don't forget to abstract-out the
> more interesting parts.  Maybe call it WALKER?

I haven't exposed myself to tree walkers yet - could you or someone give
me pointer where to read about them?

Thanks,
Pascal

--
Given any rule, however ‘fundamental’ or ‘necessary’ for science, there
are always circumstances when it is advisable not only to ignore the
rule, but to adopt its opposite. - Paul Feyerabend


 
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.
Pascal Costanza  
View profile  
 More options Nov 14 2002, 5:32 pm
Newsgroups: comp.lang.lisp
From: Pascal Costanza <costa...@web.de>
Date: Thu, 14 Nov 2002 23:32:06 +0100
Local: Thurs, Nov 14 2002 5:32 pm
Subject: Re: prog@

Barry Margolin wrote:
> One thing that bothers me about this macro: it looks like it doesn't nest
> well.  What does

> (prog@
>   @ 'outer
>   (prog@
>      @ 'inner))

> return?  I think it *should* return OUTER, but I suspect it actually
> returns INNER (I haven't tried it).

Kenny's recent post has already convinced me that I shouldn't traverse
deeply into the forms but only do a shallow traversal. Your example is
another good argument in that direction.

With a shallow traversal things get considerably simpler.

(defmacro prog! (&body body)
   (let ((result (gensym)))
     `(let ((,result nil))
        (macrolet ((! (form)
                     `(progn
                        (setq ,',result
                              (multiple-value-list ,form))
                        (values-list ,',result))))
          ,@body
          (values-list ,result)))))

So now we can do the following.

(prog!
    (...)
    (! (...))
    (...))

I like this more than other proposals with prog1/progn or (let ...)
because there, the before and after parts are not at the same level.
(This is only an aesthetical issue.)

I like Erik's proposal to use the $ sign for my macro. The ! might give
Schemers a headache. ;)

I think a proper name that includes "return" (like prog-return) instead
of a marker like ! or $ can be misleading because "return" usually means
to return immediately.

About the consing of multiple-value-list: I guess a good solution for
that would be to provide two versions, prog$ and multiple-value-prog$.
(So the above macro would be the multiple-value-prog$ version.)

Thanks again for all the comments.

Pascal

--
Given any rule, however ‘fundamental’ or ‘necessary’ for science, there
are always circumstances when it is advisable not only to ignore the
rule, but to adopt its opposite. - Paul Feyerabend


 
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 F. Burdick  
View profile  
 More options Nov 14 2002, 5:40 pm
Newsgroups: comp.lang.lisp
From: t...@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick)
Date: 14 Nov 2002 14:40:04 -0800
Local: Thurs, Nov 14 2002 5:40 pm
Subject: Re: prog@

Erik Naggum <e...@naggum.no> writes:
> * Pascal Costanza
> | I don't like ^ because it's usually inconvenient to type, and reminds me
> | of the pointer symbol in Pascal.

>   This is one case where it makes sense to think about something even
>   though it gives you painful associations.

>   ^ is unshifted above the Y on my keyboard...

Hmm, Pascal has painful memories of Pascal ...

If you're looking for positive associations, SmallTalk writes
  (return foo)
as
  ^foo
and it's got this nice up-arrow feel to it

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              


 
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.
Nils Goesche  
View profile  
 More options Nov 14 2002, 5:47 pm
Newsgroups: comp.lang.lisp
From: Nils Goesche <n...@cartan.de>
Date: 14 Nov 2002 23:47:03 +0100
Local: Thurs, Nov 14 2002 5:47 pm
Subject: Re: prog@

Pascal Costanza <costa...@web.de> writes:
> Marcus Breiing wrote:
> > Hey, when you're done with prog@, don't forget to
> > abstract-out the more interesting parts.  Maybe call it
> > WALKER?

> I haven't exposed myself to tree walkers yet - could you or
> someone give me pointer where to read about them?

Heh -- I gave you those examples to help you understand that what
you need is a fully-fledged code walker /if/ you really want to
descend into the code to replace the occurrences of @.  Just
google for ``code walker´´ to find one, or do (apropos "walk")
because many Lisp implementations already contain one.  However,
all the PROG* forms return simply one of their ``top-level´´
forms -- if you do the same, your macro would be much easier to
write -- just don't descend into the code.

Regards,
--
Nils Gösche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0


 
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 Nov 14 2002, 5:49 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 14 Nov 2002 22:49:19 +0000
Local: Thurs, Nov 14 2002 5:49 pm
Subject: Re: prog@
* Joe Marshall
| But what about trigrams......?

  The whole trigram concept was invented by a particularly dishonest Danish
  nutjob who did not want to change his keyboard.  Now, C sports bigrams,
  one of his ideas that would have been shot down if anybody had bothered
  to check his claim that "X, Y, and Z used it", which he successfully used
  to fool at least 4 different standardization organizations by arguing
  that the others used it and running around fast enough to ensure that
  that argument was self-sustaining, however circular.  It was an amazing
  example of how it is possible to use the implicit trust in decisions made
  standardization organizations can be exploited.  Even the IETF was used
  in this political game and published a horribly bug-ridden RFC that is
  /completely/ worthless.

--
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.
Pascal Costanza  
View profile  
 More options Nov 14 2002, 5:53 pm
Newsgroups: comp.lang.lisp
From: Pascal Costanza <costa...@web.de>
Date: Thu, 14 Nov 2002 23:53:48 +0100
Local: Thurs, Nov 14 2002 5:53 pm
Subject: Re: prog@

Of course - sorry!

Pascal

--
Given any rule, however ‘fundamental’ or ‘necessary’ for science, there
are always circumstances when it is advisable not only to ignore the
rule, but to adopt its opposite. - Paul Feyerabend


 
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.
Nils Goesche  
View profile  
 More options Nov 14 2002, 6:16 pm
Newsgroups: comp.lang.lisp
From: Nils Goesche <n...@cartan.de>
Date: 15 Nov 2002 00:16:03 +0100
Local: Thurs, Nov 14 2002 6:16 pm
Subject: Re: prog@

Wieso sorry?  Nur falls Du es nicht weiszt, ``Heh´´ ist Englisch
fuer ``Hehe´´, nicht ``Hey!´´ :-)

Bis denne,
--
Nils Gösche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0


 
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.
Nils Goesche  
View profile  
 More options Nov 14 2002, 6:53 pm
Newsgroups: comp.lang.lisp
From: Nils Goesche <n...@cartan.de>
Date: 15 Nov 2002 00:53:21 +0100
Local: Thurs, Nov 14 2002 6:53 pm
Subject: Re: prog@

Erik Naggum <e...@naggum.no> writes:
> * Joe Marshall
> | But what about trigrams......?

>   The whole trigram concept was invented by a particularly
>   dishonest Danish nutjob who did not want to change his
>   keyboard.

Pardon my ignorance, but google didn't help much in this case.
What are trigrams?

Regards,
--
Nils Gösche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0


 
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.
Nils Goesche  
View profile  
 More options Nov 14 2002, 6:55 pm
Newsgroups: comp.lang.lisp
From: Nils Goesche <n...@cartan.de>
Date: 15 Nov 2002 00:55:14 +0100
Local: Thurs, Nov 14 2002 6:55 pm
Subject: Re: prog@

I <n...@cartan.de> wrote:

[German gibberish]

Sorry.  Was supposed to be mailed.  Maybe I should remap the `F´
or `R´ key to some different place on my keyboard...

Regards,
--
Nils Gösche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0


 
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 Nov 14 2002, 7:11 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 15 Nov 2002 00:11:39 +0000
Local: Thurs, Nov 14 2002 7:11 pm
Subject: Re: prog@
* Nils Goesche
| Pardon my ignorance, but google didn't help much in this case.
| What are trigrams?

  A way for really stupid people to write C without changing to a rational
  keyboard layout.  I see now that they are actually called "trigraphs".
  In brief, the following replacements are made at a very early stage in
  the processing of the input files.

                               ??=   -->   #
                               ??(   -->   [
                               ??/   -->   \
                               ??)   -->   ]
                               ??'   -->   ^
                               ??<   -->   {
                               ??!   -->   |
                               ??>   -->   }
                               ??-   -->   ~

  As if this was not enough, we also have support for "digraphs":

In all aspects of the language, the six tokens

                       <:   :>   <%   %>   %:   %:%:

behave, respectively, the same as the six tokens

                       [    ]    {    }    #    ##

except for their spelling.

  The most significant consequence of these stunts is that you cannot hold
  obfuscated C contests, anymore.

--
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.
Nils Goesche  
View profile  
 More options Nov 14 2002, 9:23 pm
Newsgroups: comp.lang.lisp
From: Nils Goesche <n...@cartan.de>
Date: 15 Nov 2002 03:23:03 +0100
Local: Thurs, Nov 14 2002 9:23 pm
Subject: Re: prog@

Erik Naggum <e...@naggum.no> writes:
> * Nils Goesche
> | Pardon my ignorance, but google didn't help much in this case.
> | What are trigrams?

>   A way for really stupid people to write C without changing to
>   a rational keyboard layout.  I see now that they are actually
>   called "trigraphs".

Ah, sure.  I know these, of course.  Just one of the many things
the experienced C programmer gets bitten by once in a
while... :-( I don't remember a specific example, but I am
certain that there was more than one occasion I or a coworker got
bitten by this -- made for very hard to find bugs (always end
your exciting debug messages and comments with ?!, not with ??).

I have indeed been wondering all the time how something stupid
like this could ever enter the C standard.  Do you know the
story?  Is it written down somewhere?

Regards,
--
Nils Gösche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0


 
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 Nov 14 2002, 9:50 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 15 Nov 2002 02:50:33 +0000
Local: Thurs, Nov 14 2002 9:50 pm
Subject: Re: prog@
* Nils Goesche <n...@cartan.de>
| I have indeed been wondering all the time how something stupid like this
| could ever enter the C standard.  Do you know the story?  Is it written
| down somewhere?

  I just told the story.

--
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.
Gabe Garza  
View profile  
 More options Nov 14 2002, 9:53 pm
Newsgroups: comp.lang.lisp
From: Gabe Garza <g_ga...@ix.netcom.com>
Date: Fri, 15 Nov 2002 02:53:22 GMT
Local: Thurs, Nov 14 2002 9:53 pm
Subject: Re: prog@

"Wade Humeniuk" <w...@nospam.nowhere> writes:
> The prog-anywhere can be renamed to anything one wants.  I am
> not sure how a VALUES return could be made to work.  Also the
> flet could be replaced with a macrolet if one is concerned
> with generating anonymous functions all over the place.

Here's something along these lines that would allow multiple
values:

(defmacro prog-anywhere (returner-name &body body)
  (let ((return-values-list (gensym "RETURN-VALUES-LIST")))
    `(let (,return-values-list)
       (flet ((,returner-name (&rest values)
                (setf ,return-values-list values)))
         ,@body
         (values-list ,return-values-list)))))

* (prog-anywhere return-outer
    (multiple-value-bind (a b)
      (prog-anywhere return-inner
        1
        (return-inner 2 3)
        4
        (return-outer 5 6)
        7)
      (print (cons a b))))
(2 . 3)
5
6
*

Gabe Garza


 
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.
Nils Goesche  
View profile  
 More options Nov 14 2002, 10:18 pm
Newsgroups: comp.lang.lisp
From: Nils Goesche <n...@cartan.de>
Date: 15 Nov 2002 04:18:16 +0100
Local: Thurs, Nov 14 2002 10:18 pm
Subject: Re: prog@

Erik Naggum <e...@naggum.no> writes:
> * Nils Goesche <n...@cartan.de>
> | I have indeed been wondering all the time how something
> | stupid like this could ever enter the C standard.  Do you
> | know the story?  Is it written down somewhere?

>   I just told the story.

Yes, but I still don't know the name of the dane in question :-)
--
Nils Gösche
Ask not for whom the <CONTROL-G> tolls.

PGP key ID #xD26EF2A0


 
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 Nov 14 2002, 10:40 pm
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 15 Nov 2002 03:40:40 +0000
Local: Thurs, Nov 14 2002 10:40 pm
Subject: Re: prog@
* Nils Goesche
| Yes, but I still don't know the name of the dane in question :-)

  RFC 1345 should be a fairly good start in this regard.

--
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.
Wade Humeniuk  
View profile  
 More options Nov 14 2002, 11:50 pm
Newsgroups: comp.lang.lisp
From: "Wade Humeniuk" <w...@nospam.nowhere>
Date: Fri, 15 Nov 2002 04:50:39 GMT
Local: Thurs, Nov 14 2002 11:50 pm
Subject: Re: prog@

Nice touch with the returner-name.  I get that mind altered feeling
with the example.  It feels like it would be useful in real life (a kind of
a space connected with a whole bunch of wormholes), though I am
don't know where.  Adds a new take on the idea of spaghetti code.

Wade


 
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.
Pascal Costanza  
View profile  
 More options Nov 15 2002, 2:09 am
Newsgroups: comp.lang.lisp
From: Pascal Costanza <costa...@web.de>
Date: Fri, 15 Nov 2002 08:09:15 +0100
Local: Fri, Nov 15 2002 2:09 am
Subject: Re: prog@

Yes, but the following still doesn't work.

 > (prog-anywhere !
      5 6 7
      (! (values 42 43 44))
      8 9 10)
42

To be able to deal with multiple values is especially important when you
want to call a (predefined) function that returns multiple values.

Another question: I have seen (gensym "SOME-NAME") every now and then.
My understanding of this usage of gensym is that the generated symbols
aren't strictly unique anymore, right? Why do people still use this idiom?

Pascal

--
Given any rule, however ‘fundamental’ or ‘necessary’ for science, there
are always circumstances when it is advisable not only to ignore the
rule, but to adopt its opposite. - Paul Feyerabend


 
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.
Gabe Garza  
View profile  
 More options Nov 15 2002, 2:32 am
Newsgroups: comp.lang.lisp
From: Gabe Garza <g_ga...@ix.netcom.com>
Date: Fri, 15 Nov 2002 07:32:41 GMT
Local: Fri, Nov 15 2002 2:32 am
Subject: Re: prog@

Pascal Costanza <costa...@web.de> writes:
> Yes, but the following still doesn't work.

>  > (prog-anywhere !
>       5 6 7
>       (! (values 42 43 44))
>       8 9 10)
> 42

> To be able to deal with multiple values is especially important when
> you want to call a (predefined) function that returns multiple values.

If that's the semantics you want you could always use:

(defmacro multiple-value-prog-anywhere (returner-name &body body)
   (let ((return-values-list (gensym "RETURN-VALUES-LIST")))
     `(let (,return-values-list)
        (macrolet ((,returner-name (&body body)
                     `(setf ,',return-values-list
                            (multiple-value-list ,@body))))
         ,@body
        (values-list ,return-values-list)))))

* (multiple-value-prog-anywhere !
       5 6 7
       (! (values 42 43 44))
       8 9 10)
42
43
44
*

> Another question: I have seen (gensym "SOME-NAME") every now and
> then. My understanding of this usage of gensym is that the generated
> symbols aren't strictly unique anymore, right? Why do people still use
> this idiom?

The generated symbols are unique--that's the whole point of gensym.  I
assume you're confused over giving it a name...

In this case, I used it for ease of debugging.  Any worthy Common Lisp
environment will have a facility for macroexpanding a form so you can
see what your macros are expanding to.  For example, in ilisp if I put
the cursor before the previous example and type M-x macroexpand-lisp
the following output is displayed:

(LET (#:RETURN-VALUES-LIST2158)
  (MACROLET ((! (&BODY BODY)
               `(SETF #:RETURN-VALUES-LIST2158 (MULTIPLE-VALUE-LIST ,@BODY))))
    5
    6
    7
    (! (VALUES 42 43 44))
    8
    9
    10
    (VALUES-LIST #:RETURN-VALUES-LIST2158)))

In this case, it's not that necessary.  But in more complicated
macros, or nested macros, etc., it can be.

Gabe Garza


 
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.
Gabe Garza  
View profile  
 More options Nov 15 2002, 2:36 am
Newsgroups: comp.lang.lisp
From: Gabe Garza <g_ga...@ix.netcom.com>
Date: Fri, 15 Nov 2002 07:36:15 GMT
Local: Fri, Nov 15 2002 2:36 am
Subject: Re: prog@

Pascal Costanza <costa...@web.de> writes:
> Yes, but the following still doesn't work.

>  > (prog-anywhere !
>       5 6 7
>       (! (values 42 43 44))
>       8 9 10)
> 42

> To be able to deal with multiple values is especially important when
> you want to call a (predefined) function that returns multiple values.

If that's the semantics you want you could always use:

(defmacro multiple-value-prog-anywhere (returner-name &body body)
   (let ((return-values-list (gensym "RETURN-VALUES-LIST")))
     `(let (,return-values-list)
        (macrolet ((,returner-name (form)
                    `(setf ,',return-values-list
                            (multiple-value-list ,form))))
         ,@body
        (values-list ,return-values-list)))))

* (multiple-value-prog-anywhere !
       5 6 7
       (! (values 42 43 44))
       8 9 10)
42
43
44
*

> Another question: I have seen (gensym "SOME-NAME") every now and
> then. My understanding of this usage of gensym is that the generated
> symbols aren't strictly unique anymore, right? Why do people still use
> this idiom?

The generated symbols are unique--that's the whole point of gensym.  I
assume you're confused over giving it a name...

In this case, I used it for ease of debugging.  Any worthy Common Lisp
environment will have a facility for macroexpanding a form so you can
see what your macros are expanding to.  For example, in ilisp if I put
the cursor before the previous example and type M-x macroexpand-lisp
the following output is displayed:

(LET (#:RETURN-VALUES-LIST2158)
  (MACROLET ((! (&BODY BODY)
               `(SETF #:RETURN-VALUES-LIST2158 (MULTIPLE-VALUE-LIST ,@BODY))))
    5
    6
    7
    (! (VALUES 42 43 44))
    8
    9
    10
    (VALUES-LIST #:RETURN-VALUES-LIST2158)))

In this case, it's not that necessary.  But in more complicated
macros, or nested macros, etc., it can be.

Gabe Garza


 
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.
Pascal Costanza  
View profile  
 More options Nov 15 2002, 3:20 am
Newsgroups: comp.lang.lisp
From: Pascal Costanza <costa...@web.de>
Date: Fri, 15 Nov 2002 09:20:46 +0100
Local: Fri, Nov 15 2002 3:20 am
Subject: Re: prog@

Gabe Garza wrote:
> Pascal Costanza <costa...@web.de> writes:

>>Another question: I have seen (gensym "SOME-NAME") every now and
>>then. My understanding of this usage of gensym is that the generated
>>symbols aren't strictly unique anymore, right? Why do people still use
>>this idiom?

> The generated symbols are unique--that's the whole point of gensym.  I
> assume you're confused over giving it a name...

No, it's about the uniqueness. In the example you have given, it may be
the case that RETURN-VALUES-LIST2158 has already existed before. As far
as I understand the HyperSpec a Common Lisp implementation is not
required to take the necessary precautions against this case (whereas
(gensym) without a string argument is always guaranteed to be unique).
Right?

> (LET (#:RETURN-VALUES-LIST2158)
>   (MACROLET ((! (&BODY BODY)
>                `(SETF #:RETURN-VALUES-LIST2158 (MULTIPLE-VALUE-LIST ,@BODY))))
>     5
>     6
>     7
>     (! (VALUES 42 43 44))
>     8
>     9
>     10
>     (VALUES-LIST #:RETURN-VALUES-LIST2158)))

Pascal

--
Given any rule, however ‘fundamental’ or ‘necessary’ for science, there
are always circumstances when it is advisable not only to ignore the
rule, but to adopt its opposite. - Paul Feyerabend


 
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.
Christophe Rhodes  
View profile  
 More options Nov 15 2002, 4:09 am
Newsgroups: comp.lang.lisp
From: Christophe Rhodes <cs...@cam.ac.uk>
Date: 15 Nov 2002 09:08:46 +0000
Local: Fri, Nov 15 2002 4:08 am
Subject: Re: prog@

Wrong.

A symbol with the name RETURN-VALUES-LIST2158 may already have
existed; however, it is a different symbol from the one returned by
gensym.  The CLHS page on gensym makes this clear, when it says that
the return value is a "fresh, uninterned symbol".

  * '#:foo-1                  -> #:FOO-1
  * (setf *gensym-counter* 1) -> 1
  * (gensym "FOO-")           -> #:FOO-1
  * (eq * ***)                -> NIL

Cheers,

Christophe
--
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)


 
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 73 < Older  Newer >
« Back to Discussions « Newer topic     Older topic »