More syntactic sugar! 🍭

Hi! So Pulp is incredible already, but if you've tried to write some code using Pulpscript yet you will know that very quickly there are a few things that can get very tiresome. This is my thread to keep track of some small changes that can be made to Pulpscript to improve developer experience without causing any major rewrites.

Number 1: Adding variables to each other (and other one line math operations)
I would like to be able to write code like:

oneSecond = event.frame + 20

rather than having to do the following:

oneSecond = event.frame
oneSecond += 20

As you can see, it doesn't change any functionality, and is a common feature in most other programming languages. I understand that this may introduce an indeterminate amount of parameters, however there must be a way to implement this around the existing framework. Along the same lines:

Number 2: Multiple if/else conditions
A lot of situations call for checking many conditions before performing an action. Currently, it's time consuming and messy to nest many conditionals together to achieve this. I propose that the conditional format support compound conditionals. While adding or would be a considerable task, it should be possible to at least support and like so:

if event.frame>oneSecond and event.ra>30 then
  say "you're still spinning that crank!"
end

Number 3: Absolute function
Just a simple function that would return the absolute of a value. Instead of writing:

absoluteChange = event.ra
if absoluteChange<0 then
  absoluteChange -= event.ra
  absoluteChange -= event.ra
end

It would be much simpler to do absoluteChange = abs event.ra.

That's all for now, if you have any small things that bother you about pulpscript, put them below!

3 Likes

absolutely yes please +1 for single line math.

being able to go
variable=variable+1+OtherVariable/0.5
instead of

variable++
variable+=OtherVariable
variable/=0.5

would make my day.

or even just math in if statements
if variable==variable+othervariable then

1 Like