Re: three little issues

2011-02-06 Thread bearophile
spir: > But this does not explain why the compiler refuses: > // 1 > auto s = S(data); > return &s; > and accepts: > // 2 > return &(S(data)); > or does it? Accepting the second is a bug in the escape analysis done by the front-end, I think. But see also what Walte

Re: three little issues

2011-02-06 Thread spir
On 02/06/2011 02:13 PM, bearophile wrote: Before a D function starts, a stack frame is created. It will contain your stack-allocated struct instance. When the function ends its stack frame is destroyed virtually by moving a stack pointer, so the struct may be overwritten by other things, like

Re: three little issues

2011-02-06 Thread bearophile
spir: > 2. reference escape > 3. implicite deref The situation is easy to understand once you know how generally what a stack frame is and how C functions are called: http://en.wikipedia.org/wiki/Stack_frame The D call stack is a contiguous-allocated backwards-single-linked list of differently-

three little issues

2011-02-06 Thread spir
Hello, Here are three little issues I faced while implemented a lexing toolkit (see other post). 1. Regex match Let us say there are three "natures" or "modes" of lexeme: * SKIP: not even kept, just matched and dropped (eg optional spacing) * MARK: kept, but slice is irr