powerpatch fixes

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

powerpatch fixes

Sven Olsen

I've updated my compound assignment powerpatch, it now works reasonably well with multi-valued assignments.  Also, I've removed the link to the old 5.2.0 version of the patch; it wasn't compatible with 5.2.2, and I believe it contained bugs.

Gavin Wraith was kind enough to send me some feedback on the old 5.2.0 patch -- but I suspect he hasn't received any of the emails I've sent in reply.  So Gavin, if you're reading this: Thanks for your help, and please check out the new version.  It has less-terrible register handling.

-Sven
Reply | Threaded
Open this post in threaded view
|

Re: powerpatch fixes

Sven Olsen
(I've also posted a fix for the memory access bug in Peter Shook's "Unpack Tables by Name" power patch: http://lua-users.org/wiki/LuaPowerPatches .)
Reply | Threaded
Open this post in threaded view
|

Re: powerpatch fixes

steve donovan
In reply to this post by Sven Olsen
On Sun, Aug 18, 2013 at 6:58 AM, Sven Olsen <[hidden email]> wrote:
I've updated my compound assignment powerpatch, it now works reasonably well with multi-valued assignments.  Also, I've removed the link to the old 5.2.0 version of the patch; it wasn't compatible with 5.2.2, and I believe it contained bugs.


Sorry, Sven, it's Sunday morning and my internal C parser hasn't booted yet.  Executive summary, please!
 
Reply | Threaded
Open this post in threaded view
|

Re: powerpatch fixes

Sven Olsen
Sorry, Sven, it's Sunday morning and my internal C parser hasn't booted yet.  Executive summary, please!

Linking directly to the patch source was probably a mistake :)

But there's not a lot to summarize, honestly.  It's a compound assignment patch -- and it manages registers more correctly than the prior version, with the result that complex expressions on either side of the statement should no longer result in strange bugs.  It works with multiple assignments in the ways that you'd expect.  For example, this will work:

function a(t) return cos(t), sin(t), 1 end
vx,vy,vx+=a(t)

Obvious left hand/right hand miss matches are parse errors -- the compiler won't allow `px,py+=v`.

The patch is posted on the power patch page.  

I've also finally made good on my earlier threats of posting a combined "Sven's favorite parser hacks" patch, documentation and source for which can be found on my bio page.  Said combined patch also contains a long, rambling comment at the start of lparser.c.  It contains some of my notes on parser hacking in general, along with some comments on how the compound assignment patch is implemented.

-Sven
Reply | Threaded
Open this post in threaded view
|

Re: powerpatch fixes

steve donovan
On Sun, Aug 18, 2013 at 10:56 AM, Sven Olsen <[hidden email]> wrote:
function a(t) return cos(t), sin(t), 1 end
vx,vy,vx+=a(t)


Thanks, nice notation!  Adds our friends += etc and makes them do the obvious Lua thing!
 
Reply | Threaded
Open this post in threaded view
|

Re: powerpatch fixes

Sven Olsen

function a(t) return cos(t), sin(t), 1 end
vx,vy,vx+=a(t)


Thanks, nice notation!  Adds our friends += etc and makes them do the obvious Lua thing!
 
 
Of course, there's a typo in that line, so it will actually expand as: 
  vx=cos(t)+1
  vy=sin(t)

Perhaps we should take this as a cautionary tale illustrating the pitfalls of excessive shorthand :-)