Maximally minimal stack trace standardization

Andreas Rossberg rossberg at google.com
Mon Sep 29 09:09:22 PDT 2014


On 29 September 2014 16:55, John Lenz <concavelenz at gmail.com> wrote:
> On Sat, Sep 27, 2014 at 10:53 PM, Filip Pizlo <fpizlo at apple.com> wrote:
>> > On Sep 27, 2014, at 10:15 PM, John Lenz <concavelenz at gmail.com> wrote:
>> >
>> > I would like to get see stack traces standardized for ES7, to that end,
>> > I would like to define a minimal set of behaviors that would need to be
>> > defined:
>> >
>> > * the "stack" property (a string)
>> > * when the stack property is attached (at Error object creation or at
>> > throw)
>> > * what happens when Error object that has been thrown, is thrown again
>> > (nothing)
>> > * the stack trace in the face of tail recursion optimizations (skipped?)
>>
>> Is that really necessary?  If so, can you say something about the
>> motivation?
>>
>> You can do some tail recursion optimizations while preserving the stack
>> trace. For example if you call yourself recursively and the JIT turns it
>> into a loop, then all you need is the loop trip count to recover the
>> original stack trace.
>
> I really have no idea what the behavior should be in the faces of optimized
> tail calls (which is must broader than simply self recursive methods that
> can be rewritten as a loop).   I've seen various suggestions (a capped call
> history) but I'm curious how efficient functional languages deal with this.

Indeed, I think not enough people appreciate the (substantial)
difference between general TCO and tail recursion. If the language was
required to be able to construct stack traces then that would
effectively kill the benefit of TCO.

/Andreas


More information about the es-discuss mailing list