Re: 1 pass?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ian Andrews writes:
> Is there any reason
> that Euphoria is a one pass compiler / interpreter. As it makes
> programming recursive procedures a pain in the arse.

For normal recursion, there is no problem.
A routine can simply call itself, just like in most other
languages.

For "mutual" recursion, where A calls B which directly
or indirectly calls A, you need to use
routine_id(), and either call_func() or call_proc().
e.g.

integer B_id

procedure A()
       call_proc(B_id, {})
end procedure

procedure B()
        A()
end procedure

B_id = routine_id("B")

The fact that the language works this way
has little to do with the one-pass structure
of the compiler. It would have
been fairly easy to implement calls to routines
that are defined later, provided the call did not actually
take place until the later routine was parsed.
A one-pass compiler can "back-patch", or fill-in
missing information when it becomes available,
either later in the compile, or at run-time.

I didn't feel that making mutual recursion easier to code
was important enough to justify destroying the
"define it before you use it" property of Euphoria.
This property helps readability and maintainability.
It's not there just because Euphoria works in one-pass.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu