[Openmcl-devel] Where is the source of LET* macro

Ron Garret ron at flownet.com
Fri Apr 14 18:24:24 PDT 2023


You might want to take a look at my BINDING-BLOCK macro which combines LET/LET*, MULTIPLE-VALUE-BIND, DESTRUCTURING-BIND, FLET/LABELS, and more (it's user-extensible).

https://github.com/rongarret/ergolib/blob/master/core/binding-block.lisp <https://github.com/rongarret/ergolib/blob/master/core/binding-block.lisp>

rg

> On Apr 14, 2023, at 4:53 PM, Arthur Cater <arthur.cater at ucd.ie> wrote:
> 
> Oh dear oh dear. I’m sorry I’ve opened a can of worms. I must apologise as I wasn’t looking at the spec, but at CLtL2 which clearly says LET* is a macro.
> 
> Personally, I’d never write the code I gave as an example. I totally agree with Shannon, it’s ugly. The reason I asked is because I thought it’d be handy to write a new macro for my own use, and offer it to others, provisionally called LET**. The doc string says
> 
> LET** provides a syntax for easily combining functionality of LET* and MULTIPLE-VALUE-BIND.
> Anything you can say to LET* you can say to LET**, the converse is not true.
> …...
> 
> 
> So I wanted to make it true that "Anything you can say to LET* you can say to LET**", and this involves handling declarations the same way, and that involves understanding how LET* handles declarations, and that led to asking myself whether it was possible to bind the same name multiple times - thinking I understood LET* expanded into multiple nested LETs. CLtL2 didn’t say yea or nay, so I experimented and CCL said yea. What’s it doing then? What does it expand to? Let’s look at the macro expansion. What, it expands to itself??? Ask my openmcl friends.
> 
> And it looks like it’s a can of worms. Just yesterday I was amused to see in somebody’s blog a snapshot of the CLtL2 index  “kludges, 1-971”. 
> 
> 
> 
>> On 14 Apr 2023, at 22:01, Tim Bradshaw <tfb at tfeb.org> wrote:
>> 
>> I think this is surprisingly underspecified.  I think the only sane answer is that declarations should apply to all the bindings of a given name in a given let* (or other sequential-binding) form.
>> 
>> It is possible to check this :
>> 
>> (let (c)
>> (let ((x 1)
>>       (x (progn (setf c (lambda () x)) 2))
>>   (declare (special x))
>>   (values c (lambda () x))))
>> 
>> (sorry for paren/indentation errors, I'm typing this on a phone).  If the special declaration applies to both bindings then calling either function returned will be an error.  If it applies to only one: which, and why, and why does nothing say?  Either the spec simply omits this crucial information which would be a horrible omission, or the declarations apply to all the bindings.  Or, quite possibly I've just missed the place where it *does* say...
>> 
>> --tim
>> 
>>> On 14 Apr 2023, at 21:17, Arthur Cater <arthur.cater at ucd.ie> wrote:
>>> 
>>> I can only find a define-compiler-macro, I want to see how LET* handle declarations.
>>> It surprises me that it is apparently legal to say
>>> 
>>> ? (let* ((it 7) (it (list it it)) (it (length it))) it)
>>> 2
>>> ? 
>>> 
>>> and I wondered how declarations (if present) are treated - but I can’t find the source code.
>>> 
>>> TIA for any hep
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20230414/21837a4e/attachment.htm>


More information about the Openmcl-devel mailing list