DEV Community

Thomas Leathers
Thomas Leathers

Posted on

Constants & Variables: SSTNPL's new Integer Constants

Part 1: SSTNPL Integer background

SSTNPL (A Programming Language for my Balanced Ternary VM: SBTCVM), f has always had integer variables, as they were part of its original design. creating & using integer variables in SSTNPL is easy enough:

#create 3 variables using: decimal, ternary, & a character value.
var bob=@11
var bob2=*+0-
var bob3=:L
#dump the decimal values of each variable to SBTCVM's Terminal
dumpd bob
dumpd bob2
dumpd bob3

Part 2: The Integer Literal Syntax

However, we can also just use SSTNPL's 'literal' syntax, that's supported on most integer input arguments:

#same as above, just using the 'literal' syntax
dumpd @11
dumpd *+0-
dumpd :L

Part 3: The builtin constants

Whats changed in SSTNPL, is the introduction of a special, forth 'literal' syntax: the constant. Currently, SSTNPL has 2 of them builtin:

#$true=1, $false=0
dumpd $true
dumpd $false

Part 4: Use a custom constant to store a module's version number.

while there are still some holes (you can't use constants in var & val statements yet for example), We can use constants to provide static values that when not used, don't use up Memory:

for example, in an SSTNPL module called 'bob':

const version=@15

That way we could write an SSTNPL program like this:

#print version of bob module
prline Bob version:
dumpd $b.version

#wait for keystroke, then power-off the VM
keyprompt
stop

include bob as b

Conclusion

While SSTNPL & SBTCVM are still technically in alpha, and aren't that useful for practical purposes, I've put a lot of work into both, & hope others find programming a Balanced Ternary VM as interesting as I do.

SBTCVM Gen2-9 On github: https://github.com/SBTCVM/SBTCVM-Gen2-9
SSTNPL Language docs: https://github.com/SBTCVM/SBTCVM-Gen2-9/tree/master/textdocs/SSTNPL

👋 Do you have a minute?

Please leave your appreciation by commenting on this post!

It takes one minute and is worth it for your career.

Get started

Top comments (0)

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay