Re: Include dir as built-in function
- Posted by Jason Gade <jaygade at ?ahoo.co?> Apr 29, 2008
- 629 views
Marco Achury wrote: > > I understand that is important to keep the interpreter small. > > But I don't understand why there are a lot of function at include as: > > global function dir(sequence name) > -- returns directory information, given the name > -- of a file or directory. Format returned is: > -- { > -- {"name1", attributes, size, year, month, day, hour, minute, second}, > -- {"name2", ... }, > -- } > return machine_func(M_DIR, name) > end function > > The function is really just one line of code. M_DIR is a constant > with value 22. > > The include files are plenty of this kind of functions. > ¿How big is the effect on interpreter speed/size if some > of this functions become internals. > > Another example is function wait_key(), this is strongly used on > text mode apps, like ED.EX. > > global function wait_key() > -- Get the next key pressed by the user. > -- Wait until a key is pressed. > return machine_func(M_WAIT_KEY, 0) > end function > M_WAIT_KEY is a constant = 26 > > What gives better performance? As built-in > or as include? > > +-+-+-+-+-+-+-+ > Marco A. Achury > Caracas, Venezuela Those functions are internal (hence the machine_func() call). The reason is to avoid polluting the namespace and also probably to keep the actual reserved words in the parser relatively small. I think. Someone else could probably explain it better. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.