GNU bug report logs -
#72279
[PATCH] Non-local exits from outside the lexical scope are caught by cl-block
Previous Next
Full log
View this message in rfc822 format
Thuna <thuna.cing <at> gmail.com> writes:
>> BTW, for the second patch a simpler solution is to expand
>>
>> (cl-block A FOO)
>> to
>> (let ((cl--block--A ',(make-symbol "A")))
>> (catch cl--block--A FOO))
>>
>> and
>>
>> (cl-return B FOO)
>> to
>> (throw cl--block--B FOO)
>>
>> which will signal an "unknown variable cl--block--B" if a `cl-return` is
>> used outside of its block.
>
> Aha, yes, that would indeed be simpler.
>
>> But the optimization of `cl-block` when the tag is not used is
>> important, so I don't think it's a good approach.
>
> I don't have any particular complaints against keeping this
> optimization, but for the record would you be able to expand on what
> exactly the problem is? It doesn't seem obvious to me that unused
> `catch'es would make such a meaningful difference.
>
>> Yup, as I said, the "optimization" is important (most of the
>> `cl-block`s are implicit and unused, IME).
>
> It would be nice if this would be documented at least in a comment above
> `cl-block', even though it's unlikely that it will see too many changes.
>
>>> I see two possible solutions, either define a (setf catch) or switch
>>> to defsubst instead of cl-defsubst.
>>
>> I don't think we can implement a `setf catch` (tho we could probably
>> come up with a hack which works in practice for those
>> cl-defstruct slots). 🙁
>>
>> IIRC for the slot accessors `defsubst` would lead to worse code than
>> what we currently get with `cl-defsubst` so it wouldn't be as good, but
>> I believe we could use `define-inline` instead.
>
> That sounds like a solution. Defining a hack for `setf catch' seems
> like it would lead to a lot of problems down the line, so it would be
> better to put it off until someone comes up with a good way to do it
> (though I doubt it is possible given dynamic exits).
Thuna, I see that you got some comments in this thread. Could you
submit an updated patch based on them? Both the ones by Stefan Monnier
above, but also comments from Andrea Corallo.
Thanks in advance.
This bug report was last modified 161 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.