Log In  

@zep:

Most system 'set'-style functions return nil because they're really just procedures, not functions. In many cases, it would help to know what the value was before the new value was applied. Let me give you an example of how it could be useful:

function draw_radar()
  -- save current state + set new state
  cx,cy,cw,ch=clip(8,8,32,32)
  tx,ty=camera(-24,-24)
  c=color(3)

     ... draw green radar here ...

  -- restore saved state
  color(c)
  camera(tx,ty)
  clip(cx,cy,cw,ch)
end

It's basically a way to push and pop state in this case. There may be other uses, but this is the one I was wishing for the other day.

How does that strike you?

P#25957 2016-07-27 02:26 ( Edited 2016-07-27 06:27)


[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 15:51:21 | 0.007s | Q:11