Re: Does anyone know...

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

Michael Packard writes:
> If I have the without type_check after the include files, will it slow the
> execution of those routines when they are called?  Or is it only slowed on
> loading initially?

with/without type_check does not affect loading time.

If you have the include statements first, followed by "without type_check"
then the routines in the included files will execute slower,
although the rest of your code will be fast.

For example, some of the routines in graphics.e have parameters that are
declared with user-defined types. Whenever a call is made to one
of these routines, Euphoria will check each argument value by calling the
appropriate type function.  e.g.

type color(integer x)
    return x >= 0 and x <= 255
end type

type mixture(sequence s)
    return length(s) = 3 -- {red, green, blue}
end type

global function palette(color c, mixture s)

Whenever you call palette(), Euphoria will also call color() and mixture()
*unless* the type_check option was turned off before palette() was defined.
If you say "without type_check" *before* "include graphics.e" then
Euphoria will not call color() or mixture(), so you could pass weird
values for c or s and it wouldn't be caught. If you passed a length-4
sequence for the mixture s, I believe it would quietly use the first 3 elements
for red/green/blue and not give any error message, even though there
would clearly be something wrong with your program. If you passed a bogus
color value like -1 or 1000, I suspect it would quietly do nothing.

Now, just to really confuse you...
Even with type checking turned off, Euphoria will still
do some very simple, very fast checks. In the above example,
Euphoria will make sure that c is an integer and s is a sequence,
but it won't do any more than that, i.e. it won't call the type
functions. By doing these simple type-checks whenever a variable is written,
Euphoria can avoid similar type-checks each time the variable is read.
Variables are usually read more often than they are written.


Regards,
  Rob Craig
  Rapid Deployment Software

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

Search



Quick Links

User menu

Not signed in.

Misc Menu