Re: implementing non local returns in C++
- From: jono <raromaunga@xxxxxxxxxx>
- Date: Sun, 12 Oct 2008 13:46:17 +1300
Vend wrote:
On 11 Ott, 12:05, jono <raromau...@xxxxxxxxxx> wrote:
hi all,
can anyone suggest any resources or tricks helpful for implementing tail
calls and continuations in a Scheme interpreter built using C++?
If you are writing an interpreter then you don't need to implement the
Scheme stack as the C++ stack.
i don't need to, but i have. i currently have a great deal of transparency in translating between C++ code and Scheme code in my extension language. evaluation of nested lists is already an implicit stack, but i don't need top manage it explicitly, and thats an advantage i want to keep. you're right tho, i may need to reconsider...
C tricks such as setjmp/longjmp and stack manipulations won't cut it. i
need something that works similarly to C++ exception handling, but more
efficient.
I don't think it's possible. If it was, compiler developers would
already have implemented exceptions that way.
well, yes and no. compiler developers have optimised exception handling for error handling, which makes it too inefficient but otherwise ideal for my purposes. the inefficiency is becos the compiler makes a record of the stack as it unwinds. Stroustrup describes exceptions as a "non local control structure" that can be seen primarily as "an alternative return mechanism". he also says that implementing an exception that "isn't all that expensive compared to calling a function [...] is possible, but hard."
i guess, as i'm not prepared to develop my own compiler, i'm looking for a magic trick. surely one is out there somewhere.
-- Posted on news://freenews.netfront.net - Complaints to news@xxxxxxxxxxxx --
.
- Follow-Ups:
- Re: implementing non local returns in C++
- From: Vend
- Re: implementing non local returns in C++
- References:
- implementing non local returns in C++
- From: jono
- Re: implementing non local returns in C++
- From: Vend
- implementing non local returns in C++
- Prev by Date: Re: Was there a schism between R4RS and R5RS?
- Next by Date: Re: implementing non local returns in C++
- Previous by thread: Re: implementing non local returns in C++
- Next by thread: Re: implementing non local returns in C++
- Index(es):
Relevant Pages
|
Loading