Re: Re[2]: Multitask Feedback

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

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 :
    http://esl.sourceforge.net/
The Euphoria Standard Library mailing list :
    https://lists.sourceforge.net/lists/listinfo/esl-discussion

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

Search



Quick Links

User menu

Not signed in.

Misc Menu