Re: built-ins and include files

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

Bernie Ryan writes:
> Why are some features implemented by using machine level
> constants. If there is a machine-level constant for a given feature
> then why isn't that feature just implemented as a built-in feature
> instead of requiring an include file and the use of overhead code
> in the include file.

1. It cuts down on the number of pre-declared symbols that would
    interfere with names that you might want to use for your own
    variables and routines. i.e. it avoids "polluting the namespace"
    with lots of symbols that you don't need in all programs.
   As Euphoria grows there will be more standard include files
   and more symbols.

2. It saves some memory since built-in symbols need a symbol
    table entry that contains their name and a bunch of other
    information.

3. While the code to implement all of these machine functions is
    always present in the interpreter, at least the code to check
    the number and type of arguments can be eliminated since
    the machine functions are assumed to be called correctly.
    If you want to call a machine function directly to save the
    call overhead, go ahead, but you may see a crash if you
    pass incorrect arguments.

In most cases where the overhead of the Euphoria call is going to
matter, I've tried to make things into a built-in function.
The overhead clearly won't matter if you are doing something
like changing the graphics mode, changing the appearance of the
cursor etc. People don't do those things a million times in a tight loop.

Some routines, such as sort() and get() are written purely
in Euphoria. In these cases you do save all of the memory
required for the routine when you don't include it. These routines are
written in Euphoria rather than being implemented as builtins
because the performance seems adequate, and it saves
space in the interpreter. It's also easier to code these things
in Euphoria, and it may be educational for people to see how
they are coded.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://www.RapidEuphoria.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu