Re: Suggestions for ESL
- Posted by "Juergen Luethje" <j.lue at gmx.de> Jul 24, 2005
- 462 views
Tommy Carlier wrote: > Juergen Luethje wrote: >>> - a mechanism to ignore return-values of functions. Some options: >>> -> a global variable VOID: VOID = functionToIgnore(...) (like Win32Lib) >>> -> a procedure ignore that does nothing: ignore(functionToIgnore()) (like >>> Win4Eu) >> >> I like both suggestions. Hard to say which one is "better". > > I like the ignore-procedure, because it can only be used for ignoring stuff. > The global variable VOID can be used for storing temporary data and can be > passed to other routines, and that's not its purpose. I also think it reads > better. The code just says what it does: it calls a function and 'ignores' > the return value. That sounds reasonable. >>> - an enumeration-mechanism: here's how it was done in Win4Eu: >>> }}} <eucode> >>> constant DAY_OF_WEEK = enum() >>> constant MONDAY = next(DAY_OF_WEEK), >>> TUESDAY = next(DAY_OF_WEEK), >>> WEDNESDAY = next(DAY_OF_WEEK), >>> THURSDAY = next(DAY_OF_WEEK), >>> FRIDAY = next(DAY_OF_WEEK), >>> SATURDAY = next(DAY_OF_WEEK), >>> SUNDAY = next(DAY_OF_WEEK) >> </eucode> {{{ </font> >> >> Sorry, I don't understand. >> Should the function next() be in the library, and the code above is in >> the user's program? Or should all the code above be in the library? > > I'm talking about the enum- and next-function. The code above is just an > example of how to use it. It's a higher-level alternative for this: > }}} <eucode> > constant MONDAY = 1, > TUESDAY = 2, > WEDNESDAY = 3, > THURSDAY = 4, > FRIDAY = 5, > SATURDAY = 6, > SUNDAY = 7 > </eucode> {{{ > The advantage of using enum, is that you can later insert extra values > without having to renumber the existing ones. I really like to have an enum "mechanism". Just when I first read your example above, it looked magically to me, and I couldn't imagine how it works. I saw, that in the meantime you posted the source code for enum() and next(). Very cool! Regards, Juergen