keith-packard / snek

Snek programming language for tiny systems
GNU General Public License v3.0
294 stars 30 forks source link

print and printn add '0' in the end of line #4

Closed eamanu closed 5 years ago

eamanu commented 5 years ago

Hello,

When I use the built-in functions print and printn this add a '0' on the end of the line:

image

eamanu commented 5 years ago

newt_builtin_print* is returned NEWT_ZERO. Why? if it is just a print why return? I propose use a "wrapper" that call to existing newt_built_print* instructions but returning void

keith-packard commented 5 years ago

Newt doesn't have 'void' values, so every function has to return 'something'. The top level interpreter loop prints the value for every expression evaluated so you can see the value of something like '1+1'. As 'print' returns 0, that's what you see in the output. Python has a 'void' value which lets it tell when an expression has an interesting result and when it doesn't. So, this is working 'as designed', but I agree that it might be nice if a 'void' value were added so that you wouldn't see this noise.

eamanu commented 5 years ago

Great! Could I take this enhancement, please?

keith-packard commented 5 years ago

Sorry, missed your comment from last month! Of course, if you want to add a 'void' value to avoid printing spurious zeros, that would be fun to see.