* Re: [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature. [not found] <E1XYzSf-00075J-Dr@vcs.savannah.gnu.org> @ 2014-09-30 17:55 ` Stefan Monnier 2014-09-30 19:15 ` Paul Eggert 0 siblings, 1 reply; 6+ messages in thread From: Stefan Monnier @ 2014-09-30 17:55 UTC (permalink / raw) To: Dmitry Antipov; +Cc: emacs-devel > + In C, this is implemented as a special macros which expands to > +a @code{Lisp_Object} with block-scoped semantics and lifetime (see > +the code around @code{USE_STACK_LISP_OBJECTS} in @file{lisp.h}). This > +means that these objects are not managed by the garbage collector; > +instead, they are allocated like local variables in C and automatically > +freed when an execution reaches an end of the corresponding scope. Thus, > +allocation and freeing are faster than using garbage collector. But > +remember that passing them out of their scope results in undefined > +behavior. Think twice before using this feature and carefully debug > +your code with @code{GC_CHECK_MARKED_OBJECTS} (see @file{alloc.c}). I'm an old-style programmer, so I don't know C99 and I hence don't know what is the "corresponding scope" of those new thingies. See my other message about these macros. I'd much prefer declaration-level macros, which would come with clear scoping. Stefan ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature. 2014-09-30 17:55 ` [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature Stefan Monnier @ 2014-09-30 19:15 ` Paul Eggert 2014-09-30 19:29 ` Eli Zaretskii 2014-09-30 20:20 ` Stefan Monnier 0 siblings, 2 replies; 6+ messages in thread From: Paul Eggert @ 2014-09-30 19:15 UTC (permalink / raw) To: emacs-devel On 09/30/2014 10:55 AM, Stefan Monnier wrote: > I don't know C99 and I hence don't know > what is the "corresponding scope" of those new thingies. I gave a shot at improving that part of the documentation in trunk bzr 117990. > See my other message about these macros. Sorry, I don't remember which message that was? > I'd much prefer > declaration-level macros, which would come with clear scoping. Although I can see the attraction of their clearer scoping, requiring a name for every temporary can make code considerably harder to read. 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); 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....) 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.) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature. 2014-09-30 19:15 ` Paul Eggert @ 2014-09-30 19:29 ` Eli Zaretskii 2014-09-30 19:49 ` David Kastrup 2014-09-30 20:20 ` Stefan Monnier 1 sibling, 1 reply; 6+ messages in thread From: Eli Zaretskii @ 2014-09-30 19:29 UTC (permalink / raw) To: Paul Eggert; +Cc: emacs-devel > Date: Tue, 30 Sep 2014 12:15:34 -0700 > From: Paul Eggert <eggert@cs.ucla.edu> > > Regardless of whether we use declaration-style macros, there is one > thing I'd like to change: the macro names. Yes, the names are not helpful. > 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....) Or maybe "alloca_*", as in alloca_string, alloca_list1, etc. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature. 2014-09-30 19:29 ` Eli Zaretskii @ 2014-09-30 19:49 ` David Kastrup 0 siblings, 0 replies; 6+ messages in thread From: David Kastrup @ 2014-09-30 19:49 UTC (permalink / raw) To: emacs-devel Eli Zaretskii <eliz@gnu.org> writes: >> Date: Tue, 30 Sep 2014 12:15:34 -0700 >> From: Paul Eggert <eggert@cs.ucla.edu> >> >> Regardless of whether we use declaration-style macros, there is one >> thing I'd like to change: the macro names. > > Yes, the names are not helpful. > >> 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....) > > Or maybe "alloca_*", as in alloca_string, alloca_list1, etc. alloca is "to end of function". Language-supported dynamic allocations are "to end of block". That's not quite the same. -- David Kastrup ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature. 2014-09-30 19:15 ` Paul Eggert 2014-09-30 19:29 ` Eli Zaretskii @ 2014-09-30 20:20 ` Stefan Monnier 2014-10-01 3:31 ` Paul Eggert 1 sibling, 1 reply; 6+ messages in thread From: Stefan Monnier @ 2014-09-30 20:20 UTC (permalink / raw) To: Paul Eggert; +Cc: emacs-devel > 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature. 2014-09-30 20:20 ` Stefan Monnier @ 2014-10-01 3:31 ` Paul Eggert 0 siblings, 0 replies; 6+ messages in thread From: Paul Eggert @ 2014-10-01 3:31 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel Stefan Monnier wrote: > Well, the second looks much better to me. Its semantics is much clearer. OK, I gave that a shot in trunk bzr 117994. I used the prefix 'AUTO_', as it's shorter and more-specific than 'STACK_ALLOC_'. It turned out better than I expected, and thanks for the suggestion. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-10-01 3:31 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <E1XYzSf-00075J-Dr@vcs.savannah.gnu.org> 2014-09-30 17:55 ` [Emacs-diffs] trunk r117987: * internals.texi (Stack-allocated Objects): Describe this feature Stefan Monnier 2014-09-30 19:15 ` Paul Eggert 2014-09-30 19:29 ` Eli Zaretskii 2014-09-30 19:49 ` David Kastrup 2014-09-30 20:20 ` Stefan Monnier 2014-10-01 3:31 ` Paul Eggert
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).