[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objec
From: |
Stefan Monnier |
Subject: |
Re: [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature. |
Date: |
Tue, 30 Sep 2014 16:20:01 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
> For example, we'd have to replace this:
> caller = concat3 (SCOPED_STRING (" <"), caller, SCOPED_STRING (">"));
> with something like this:
> SCOPED_STRING (space_lessthan, " <");
> SCOPED_STRING (greaterthan, ">");
> caller = concat3 (space_lessthan, caller, greaterthan);
Well, the second looks much better to me. Its semantics is much clearer.
The extra verbosity helps the programmer think a bit harder about what
she's doing and whether it is really safe to use stack allocation.
> Regardless of whether we use declaration-style macros, there is one thing
> I'd like to change: the macro names. These macros are not about *scope*;
> they are about *lifetime*. How about the prefix "auto_" (from the C keyword
> 'auto') rather than "scope_"? Or maybe "block_" because it's block
> lifetime? ("auto_" is shorter....)
Maybe it's too obvious, but how 'bout STACK_ALLOC_STRING?
Bikeshedding et al.
> Also, I capitalized SCOPED_STRING on the theory that it is often not
> implemented as a function. On second thought since it can be (and sometimes
> is) implemented as a function I'm thinking we should make it lower-case, as
> scoped_cons etc. are. (Correcting its prefix of course.)
That's another advantage of the declaration version: there's no arguing
whether it should be capitalized or not, since it can't be implemented
as a function.
Stefan