[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: CL vs scheme macros, namespaces.

William James

3/25/2015 8:53:00 AM

Pascal Bourguignon wrote:

> To take a simple example:
>
> (define-syntax -->
> (syntax-rules ()
> ((_ . original)
> (-->helper () original))))
>
> (define-syntax -->helper
> (syntax-rules ()
> ((_ pairs (x0 y0 . more))
> (-->helper ((x0 y0) . pairs) more))
> ((_ pairs body)
> (let pairs . body))))
>
>
>
> (defmacro --> (&rest [var-val]*-body)
> `(let ,(loop for (var val) on (butlast [var-val]*-body) by (function cddr)
> collect (list var val))
> ,@(last [var-val]*-body)))

The helper macro isn't needed.

Scheme (Gauche and Racket):

The goal is a let-macro that doesn't need parentheses
around the bindings. Only one expression is allowed
after the bindings.

;; Pattern-matching is powerful and fun.
(define-syntax -->
(syntax-rules ()
( [_ pairs body] (let pairs body))
( [_ (k-v ...) k v more ...] (--> (k-v ... (k v)) more ...))
( [_ more ...] (--> () more ...))))


gosh> (--> a 2 m 44 z 88 (print (list a m z)))
(2 44 88)

You can even give the macro a leg up if you wish:

gosh> (--> () a 2 m 44 z 88 (print (list a m z)))
(2 44 88)
gosh> (--> ((q 500)) a 2 m 44 z 88 (print (list a m z q)))
(2 44 88 500)

You can even specify the let-bindings in the usual way:

gosh> (--> ((a 2) (m 44) (z 88)) (print (list a m z)))
(2 44 88)
8 Answers

suzeeq

2/20/2014 4:04:00 PM

0

EGK wrote:
> On Thu, 20 Feb 2014 07:52:09 -0700, suzeeq <suzee@imbris.com> wrote:
>
>> Adam H. Kerman wrote:
>>> suzeeq <suzee@imbris.com> wrote:
>>>> Adam H. Kerman wrote:
>>>>> Hunter <buffhunter@my-deja.com> wrote:
>>>>>> no_offline_contact_please@example.com says...
>>>>>>>> http://blogs.indiewire.com/theplaylist/watch-the-amazing-full-6-minute-tracking-shot-from-true-detectiv...
>>>>>>>> Watch: The Amazing Full 6-Minute Tracking Shot From 'True Detective'
>>>>>>>> Firstly, if you're not watching HBO's "True Detective," you're doing
>>>>>>>> it wrong.
>>>>>>>> <I laboriously plodded through the first ep that had me swimming in
>>>>>>>> exposition and looking at my fictional watch however I am thankful
>>>>>>>> that I stuck through it and made it to ep 2 since this series has
>>>>>>>> quickly turned in to must see tv for me. I find the performances
>>>>>>>> exceptional and the competing story lines captivating. And not for
>>>>>>>> nothing it has Michelle Monaghan. Perhaps it is just me but when Woody
>>>>>>>> Harrelson came on screen his "cop's" countenance immediately brought
>>>>>>>> to mind Gregory Medavoy of NYPD Blue. I have no idea where this is
>>>>>>>> going to end up but sometimes I think that when all is said and done
>>>>>>>> and the detectives are finished interviewing Harrelson they are going
>>>>>>>> to stand up and cuff him. I am also not certain of the exact timeline
>>>>>>>> of the interviews and whether or not they are taking place somewhat
>>>>>>>> concurrently.
>>>>>>> While there hasn't been much in the dialogue to clue you in, there were
>>>>>>> captions on the screen that indicated that the two stories - the
>>>>>>> investigation of the murder and the interviews of the original
>>>>>>> detectives - took place in 1997 and 2012 respectively.
>>>>>> You can tell that by just looking at them. The inteviews in whcih one has a
>>>>>> receding hair line (Det. Martin Hart) and the other looks like a tired old
>>>>>> hippie (Det. Rustin Cohle) are from 2012.
>>>>> Dear gawd... How the fuck can I tell that the "present" story is 2012 from
>>>>> the receding hairline and tired old hippie? There's nothing time specific
>>>>> in that room, other than the two detectives are telling a story from many
>>>>> years past.
>>>> The main characters are made up to look older than in the scenes with
>>>> the action. Geeze, the interviews only are in the 'present' while
>>>> everything else is in the past.
>>> Is it really necessary to point out that you missed the obvious
>>> sarcasm?
>> Sarcasm? Then all your posts must be sarcastic because you use that same
>> tone in them.
>>
>>> Hunter insisted he could tell what year it was from the makeup,
>>> as opposed to the screen caption.
>> Well so can I.
>
> Me too. All you have to look at his Woody's hair. I read an article where
> he said they just put a wig on him to make him look younger.

That's what I figured. And a wig on Michael to make his longer and look
older.

Dano

2/20/2014 5:10:00 PM

0

"suzeeq" wrote in message news:le5924$48s$2@dont-email.me...

EGK wrote:
> On Thu, 20 Feb 2014 07:52:09 -0700, suzeeq <suzee@imbris.com> wrote:
>
>> Adam H. Kerman wrote:
>>> suzeeq <suzee@imbris.com> wrote:
>>>> Adam H. Kerman wrote:
>>>>> Hunter <buffhunter@my-deja.com> wrote:
>>>>>> no_offline_contact_please@example.com says...
>>>>>>>> http://blogs.indiewire.com/theplaylist/watch-the-amazing-full-6-minute-tracking-shot-from-true-detectiv...
>>>>>>>> Watch: The Amazing Full 6-Minute Tracking Shot From 'True
>>>>>>>> Detective'
>>>>>>>> Firstly, if you're not watching HBO's "True Detective," you're
>>>>>>>> doing
>>>>>>>> it wrong.
>>>>>>>> <I laboriously plodded through the first ep that had me swimming in
>>>>>>>> exposition and looking at my fictional watch however I am thankful
>>>>>>>> that I stuck through it and made it to ep 2 since this series has
>>>>>>>> quickly turned in to must see tv for me. I find the performances
>>>>>>>> exceptional and the competing story lines captivating. And not for
>>>>>>>> nothing it has Michelle Monaghan. Perhaps it is just me but when
>>>>>>>> Woody
>>>>>>>> Harrelson came on screen his "cop's" countenance immediately
>>>>>>>> brought
>>>>>>>> to mind Gregory Medavoy of NYPD Blue. I have no idea where this is
>>>>>>>> going to end up but sometimes I think that when all is said and
>>>>>>>> done
>>>>>>>> and the detectives are finished interviewing Harrelson they are
>>>>>>>> going
>>>>>>>> to stand up and cuff him. I am also not certain of the exact
>>>>>>>> timeline
>>>>>>>> of the interviews and whether or not they are taking place somewhat
>>>>>>>> concurrently.
>>>>>>> While there hasn't been much in the dialogue to clue you in, there
>>>>>>> were captions on the screen that indicated that the two stories -
>>>>>>> the investigation of the murder and the interviews of the original
>>>>>>> detectives - took place in 1997 and 2012 respectively.
>>>>>> You can tell that by just looking at them. The inteviews in whcih one
>>>>>> has a receding hair line (Det. Martin Hart) and the other looks like
>>>>>> a tired old hippie (Det. Rustin Cohle) are from 2012.
>>>>> Dear gawd... How the fuck can I tell that the "present" story is 2012
>>>>> from
>>>>> the receding hairline and tired old hippie? There's nothing time
>>>>> specific
>>>>> in that room, other than the two detectives are telling a story from
>>>>> many
>>>>> years past.
>>>> The main characters are made up to look older than in the scenes with
>>>> the action. Geeze, the interviews only are in the 'present' while
>>>> everything else is in the past.
>>> Is it really necessary to point out that you missed the obvious
>>> sarcasm?
>> Sarcasm? Then all your posts must be sarcastic because you use that same
>> tone in them.
>>
>>> Hunter insisted he could tell what year it was from the makeup,
>>> as opposed to the screen caption.
>> Well so can I.
>
> Me too. All you have to look at his Woody's hair. I read an article
> where
> he said they just put a wig on him to make him look younger.

That's what I figured. And a wig on Michael to make his longer and look
older.

==============================================

If you mean McConaughey (Matt), he's reputed to be such a maniac, it's
probably all real on him.

jess stone

2/20/2014 6:31:00 PM

0

On Thu, 20 Feb 2014 15:52:14 +0000 (UTC), "Adam H. Kerman"

snips

>Yes, dear. Lemme be the first to inform you that I can be rather sarcastic
>on Usenet.

You said Usenet. Is that you grandpa?

thinbluemime

2/20/2014 6:40:00 PM

0

On Thu, 20 Feb 2014 13:31:08 -0500, jess stone <jessstone@gmail.com> wrote:

> On Thu, 20 Feb 2014 15:52:14 +0000 (UTC), "Adam H. Kerman"
> snips
>
>> Yes, dear. Lemme be the first to inform you that I can be rather
>> sarcastic
>> on Usenet.
>
> You said Usenet. Is that you grandpa?

No, that's the old thing grandma puts on her head in the kitchen to keep
hairs out of the vittles.

--
This communication may be unlawfully collected and stored by the National
Security Agency (NSA) in secret. The parties to this email do not consent
to the retrieving or storing of this communication and any related
metadata, as well as printing, copying, re-transmitting, disseminating, or
otherwise using it. If you believe you have received this communication in
error, please delete it immediately.

suzeeq

2/20/2014 6:49:00 PM

0

Adam H. Kerman wrote:
> suzeeq <suzee@imbris.com> wrote:
>> Adam H. Kerman wrote:
>>> suzeeq <suzee@imbris.com> wrote:
>>>> Adam H. Kerman wrote:
>>>>> Hunter <buffhunter@my-deja.com> wrote:
>>>>>> no_offline_contact_please@example.com says...
>
>>>>>>>> http://blogs.indiewire.com/theplaylist/watch-the-amazing-full-6-minute-tracking-shot-from-true-detectiv...
>
>>>>>>>> Watch: The Amazing Full 6-Minute Tracking Shot From 'True Detective'
>
>>>>>>>> Firstly, if you're not watching HBO's "True Detective," you're doing
>>>>>>>> it wrong.
>
>>>>>>>> <I laboriously plodded through the first ep that had me swimming in
>>>>>>>> exposition and looking at my fictional watch however I am thankful
>>>>>>>> that I stuck through it and made it to ep 2 since this series has
>>>>>>>> quickly turned in to must see tv for me. I find the performances
>>>>>>>> exceptional and the competing story lines captivating. And not for
>>>>>>>> nothing it has Michelle Monaghan. Perhaps it is just me but when Woody
>>>>>>>> Harrelson came on screen his "cop's" countenance immediately brought
>>>>>>>> to mind Gregory Medavoy of NYPD Blue. I have no idea where this is
>>>>>>>> going to end up but sometimes I think that when all is said and done
>>>>>>>> and the detectives are finished interviewing Harrelson they are going
>>>>>>>> to stand up and cuff him. I am also not certain of the exact timeline
>>>>>>>> of the interviews and whether or not they are taking place somewhat
>>>>>>>> concurrently.
>
>>>>>>> While there hasn't been much in the dialogue to clue you in, there were
>>>>>>> captions on the screen that indicated that the two stories - the
>>>>>>> investigation of the murder and the interviews of the original
>>>>>>> detectives - took place in 1997 and 2012 respectively.
>
>>>>>> You can tell that by just looking at them. The inteviews in whcih
>>>>>> one has a receding hair line (Det. Martin Hart) and the other looks
>>>>>> like a tired old hippie (Det. Rustin Cohle) are from 2012.
>
>>>>> Dear gawd... How the fuck can I tell that the "present" story is 2012 from
>>>>> the receding hairline and tired old hippie? There's nothing time specific
>>>>> in that room, other than the two detectives are telling a story from many
>>>>> years past.
>
>>>> The main characters are made up to look older than in the scenes with
>>>> the action. Geeze, the interviews only are in the 'present' while
>>>> everything else is in the past.
>
>>> Is it really necessary to point out that you missed the obvious
>>> sarcasm?
>
>> Sarcasm? Then all your posts must be sarcastic because you use that same
>> tone in them.
>
> Yes, dear. Lemme be the first to inform you that I can be rather sarcastic
> on Usenet.
>
>>> Hunter insisted he could tell what year it was from the makeup,
>>> as opposed to the screen caption.
>
>> Well so can I.
>
> And it wasn't 2009, 2010, 2011, 2013, or 2014? Could you tell it was May 23,
> 2012, versus July 7, 2012, based on how much Hart's hairline had receded?

Why do you think it was two separate days in 2012?

> You and hunter are geneyouuses.

Sure we are, even though we don't have PhDs...

suzeeq

2/20/2014 6:51:00 PM

0

Dano wrote:
> "suzeeq" wrote in message news:le5924$48s$2@dont-email.me...
>
> EGK wrote:
>> On Thu, 20 Feb 2014 07:52:09 -0700, suzeeq <suzee@imbris.com> wrote:
>>
>>> Adam H. Kerman wrote:
>>>> suzeeq <suzee@imbris.com> wrote:
>>>>> Adam H. Kerman wrote:
>>>>>> Hunter <buffhunter@my-deja.com> wrote:
>>>>>>> no_offline_contact_please@example.com says...
>>>>>>>>> http://blogs.indiewire.com/theplaylist/watch-the-amazing-full-6-minute-tracking-shot-from-true-detectiv...
>>>>>>>>> Watch: The Amazing Full 6-Minute Tracking Shot From 'True
>>>>>>>>> Detective'
>>>>>>>>> Firstly, if you're not watching HBO's "True Detective," you're
>>>>>>>>> doing
>>>>>>>>> it wrong.
>>>>>>>>> <I laboriously plodded through the first ep that had me swimming in
>>>>>>>>> exposition and looking at my fictional watch however I am thankful
>>>>>>>>> that I stuck through it and made it to ep 2 since this series has
>>>>>>>>> quickly turned in to must see tv for me. I find the performances
>>>>>>>>> exceptional and the competing story lines captivating. And not for
>>>>>>>>> nothing it has Michelle Monaghan. Perhaps it is just me but when
>>>>>>>>> Woody
>>>>>>>>> Harrelson came on screen his "cop's" countenance immediately
>>>>>>>>> brought
>>>>>>>>> to mind Gregory Medavoy of NYPD Blue. I have no idea where this is
>>>>>>>>> going to end up but sometimes I think that when all is said and
>>>>>>>>> done
>>>>>>>>> and the detectives are finished interviewing Harrelson they are
>>>>>>>>> going
>>>>>>>>> to stand up and cuff him. I am also not certain of the exact
>>>>>>>>> timeline
>>>>>>>>> of the interviews and whether or not they are taking place somewhat
>>>>>>>>> concurrently.
>>>>>>>> While there hasn't been much in the dialogue to clue you in, there
>>>>>>>> were captions on the screen that indicated that the two stories -
>>>>>>>> the investigation of the murder and the interviews of the original
>>>>>>>> detectives - took place in 1997 and 2012 respectively.
>>>>>>> You can tell that by just looking at them. The inteviews in whcih one
>>>>>>> has a receding hair line (Det. Martin Hart) and the other looks like
>>>>>>> a tired old hippie (Det. Rustin Cohle) are from 2012.
>>>>>> Dear gawd... How the fuck can I tell that the "present" story is 2012
>>>>>> from
>>>>>> the receding hairline and tired old hippie? There's nothing time
>>>>>> specific
>>>>>> in that room, other than the two detectives are telling a story from
>>>>>> many
>>>>>> years past.
>>>>> The main characters are made up to look older than in the scenes with
>>>>> the action. Geeze, the interviews only are in the 'present' while
>>>>> everything else is in the past.
>>>> Is it really necessary to point out that you missed the obvious
>>>> sarcasm?
>>> Sarcasm? Then all your posts must be sarcastic because you use that same
>>> tone in them.
>>>
>>>> Hunter insisted he could tell what year it was from the makeup,
>>>> as opposed to the screen caption.
>>> Well so can I.
>> Me too. All you have to look at his Woody's hair. I read an article
>> where
>> he said they just put a wig on him to make him look younger.
>
> That's what I figured. And a wig on Michael to make his longer and look
> older.
>
> ==============================================
>
> If you mean McConaughey (Matt), he's reputed to be such a maniac, it's
> probably all real on him.

Matt yeah, I got him confused with the name of that awful movie he was in.

It takes a long time to grow hair that long from his more normal short
cut, so I thought it was probably a wig, rather than he'd grown it and
they filmed those scenes first, then cut it for the rest of them.

suzeeq

2/20/2014 6:51:00 PM

0

jess stone wrote:
> On Thu, 20 Feb 2014 15:52:14 +0000 (UTC), "Adam H. Kerman"
>
> snips
>
>> Yes, dear. Lemme be the first to inform you that I can be rather sarcastic
>> on Usenet.
>
> You said Usenet. Is that you grandpa?

This is usenet, not google groups.

William James

3/25/2015 9:16:00 AM

0

WJ wrote:

> Pascal Bourguignon wrote:
>
> > To take a simple example:
> >
> > (define-syntax -->
> > (syntax-rules ()
> > ((_ . original)
> > (-->helper () original))))
> >
> > (define-syntax -->helper
> > (syntax-rules ()
> > ((_ pairs (x0 y0 . more))
> > (-->helper ((x0 y0) . pairs) more))
> > ((_ pairs body)
> > (let pairs . body))))
> >
> >
> >
> > (defmacro --> (&rest [var-val]*-body)
> > `(let ,(loop for (var val) on (butlast [var-val]*-body) by (function cddr)
> > collect (list var val))
> > ,@(last [var-val]*-body)))
>
> The helper macro isn't needed.
>
> Scheme (Gauche and Racket):
>
> The goal is a let-macro that doesn't need parentheses
> around the bindings. Only one expression is allowed
> after the bindings.
>
> ;; Pattern-matching is powerful and fun.
> (define-syntax -->
> (syntax-rules ()
> ( [_ pairs body] (let pairs body))
> ( [_ (k-v ...) k v more ...] (--> (k-v ... (k v)) more ...))
> ( [_ more ...] (--> () more ...))))
>
>
> gosh> (--> a 2 m 44 z 88 (print (list a m z)))
> (2 44 88)
>
> You can even give the macro a leg up if you wish:
>
> gosh> (--> () a 2 m 44 z 88 (print (list a m z)))
> (2 44 88)
> gosh> (--> ((q 500)) a 2 m 44 z 88 (print (list a m z q)))
> (2 44 88 500)
>
> You can even specify the let-bindings in the usual way:
>
> gosh> (--> ((a 2) (m 44) (z 88)) (print (list a m z)))
> (2 44 88)

With some error checking:

(define-syntax -->
(syntax-rules ()
( [_ pairs body] (let pairs body))
( [_ (k-v ...) k v more ...] (--> (k-v ... (k v)) more ...))
( [_ thing] (syntax-error "Error in macro -->."))
( [_ more ...] (--> () more ...))))

gosh> (lambda () (--> a 2 b (list a b)) )
*** ERROR: Compile Error: Error in macro -->.