Re: Re[2]: Multitask Feedback

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

D. Newhall wrote:
> 
> Al Getz wrote:
> > 
> > Hi there,
> > 
> > That's a good idea.  I can go either way with this though.  After all,
> > it doesnt take too much to ignore a return value, yet it wouldnt take
> > any new keyword to modify the language either.
> > 
> >   i=seek(fn,a) --i need the return value
> >   seek(fn,a)   --i dont need the return value
> > 
> > It's also hard to believe this would cause many problems, because
> > im wondering who could make an error like these:
> > 
> >   seek(fn,a)  --whoops!  I really needed the return value here! :)
> > 
> >   i=seek(fn,a) --Oh geeze!  I didnt really need the return value here! :)
> > 
> > Would anyone make this kind of error if it worked both ways?
> > 
> > With my C compiler (not sure if this is typical for compilers) it
> > allows you to call Win API functions as either a function when you need
> > the return value:
> >   c=SetColor(new)
> > or as a procedure when you dont:
> >   SetColor(new)
> >   
> > 
> > I think most people do something like this in Euphoria...
> > 
> >   object void --local or global
> >   void=seek(fn,a)
> >   void=SomethingElse()
> >   etc.
> > 
> > although Rob seems to prefer:
> > 
> >   if seek(fn,a) then end if
> > 
> > 
> > Take care,
> > Al
> > 
> > And, good luck with your Euphoria programming!
> > 
> > My bumper sticker: "I brake for LED's"
> > 
> 
> The "problem" with simply ignoring the return value if no variable assignment
> is before
> it is if you forget to put the assignment in when you meant to and your code
> works
> but not correctly and I think that that could be a hard bug to find.
> Especially if
> you're converting C code to Euphoria, for example, since C's open() doesn't
> return
> a value so if you forget the assignment while translating and you do a quick
> scan over
> your code and you forget to make the distinction between C and Euphoria's
> open() it
> might take you a while to figure out where the bug is. While that argument
> does seem
> a  bit forced I can see simply ignoring the return values of functions without
> an assignment
> causing a lot of problems for some programmers because it's not a very
> apparent bug
> and if you didn't define the routines you are using (ie. you're using another
> person's
> library) you might have no idea while your code isn't working.
> 
> 
> Bernie Ryan wrote:
> >
> > derek:
> >    Why not just use this; your way has the overhead of an extra call ?
> >
> >
> > object ignore
> >
> > ignore = seek(fn, 100)
> 
> You can do that too (and many times I do as well) however in most cases the
> extra procedure
> call doesn't add much and I think it's clearer because maybe the variable is
> named
> ignore for some other reason? Also, with this method (and this is simply me
> being a
> lazy programmer) I have a tendency to use the variable ignore in tests and as
> a temporary
> variable rather than redeclare it so I've beeen known to use an "ignored"
> variable
> for a good length of code :P, the procedure version makes sure I can't do
> that.
> 
> 
> The Euphoria Standard Library project :
>     <a href="http://esl.sourceforge.net/">http://esl.sourceforge.net/</a>
> The Euphoria Standard Library mailing list :
>     <a
>     href="https://lists.sourceforge.net/lists/listinfo/esl-discussion">https://lists.sourceforge.net/lists/listinfo/esl-discussion</a>
> 

I just use a dummy IF statement to ignore function return values. It doesnt
cause any overhead that I'm aware of. Graphics_mode() is a good example of a
function that I rarely need the return value for.

-- Example (DOS-32)

without type_check
without warning

constant GRAPHICS_MODE = 5,
	 TEXT_COLOR = 9,
	 VIDEO_CONFIG = 13,
	 WAIT_KEY = 26

sequence vConfig

if machine_func(GRAPHICS_MODE, 13) then end if
vConfig = machine_func(VIDEO_CONFIG, 0)
position(vConfig[3]/2, vConfig[4]/2.6)
machine_proc(TEXT_COLOR, 12)
puts(1, "Hello There!")
machine_proc(WAIT_KEY, 0)
if machine_func(GRAPHICS_MODE, -1) then end if



Regards,
Vincent

----------------------------------------------
     ___	      __________      ___
    /__/\            /__________\    |\ _\
    \::\'\          //::::::::::\\   |'|::|
     \::\'\        //:::_::::_:::\\  |'|::|
      \::\'\      //::/  |::|  \::\\ |'|::|
       \::\'\    //::/   |::|   \::\\|'|::|
        \::\'\__//::/    |::|    \::\|'|::|
         \::\','/::/     |::|     \::\\|::|
          \::\_/::/      |::|      \::\|::|
           \::,::/       |::|       \:::::|
            \___/        |__|        \____|

 	                 .``.
		         ',,'

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

Search



Quick Links

User menu

Not signed in.

Misc Menu