theRAPTLab / gsgo

GEM-STEP Foundation repo migrated from GitLab June 2023
1 stars 1 forks source link

Constants (document abandoned feature) #774

Open benloh opened 9 months ago

benloh commented 9 months ago

This is working code, but has not been merged.


The original implementation for "enums" #755 was to implement them as constants. This essentially created a system parallel to props to define static properties and set properties to the defined constant values.

This added two new keywords:

Ultimately this was abandoned because:

The main goal of adding "enums" was make it easier for students to modify code. The stack syntax ultimately made it more difficult to use.

See branch dev-bl/constants for code.


Test Scripts

// Constant Explorations
// String Contant
addConstant PRODUCER string 'prod'
addConstant CONSUMER string 'cons'
addConstant DECOMPOSER string 'decomp'
// set constant via propPop -- Test to make sure we're getting the right value
constantPush PRODUCER
dbgStack
// set constant via propPop -- do it
constantPush PRODUCER
propPop character.entityType
// do we need to suport globals?
// doesn't work yet -- need to fix class-som-bojects.getConstnat pName.split'
// constantPush global.DEAD

// setToConstant -- doesn't work because we can't do assignments with prop
addProp entityType string 'unset'
prop character.entityType setToConstant PRODUCER
exprPush {{ character.prop.entityType.value }}
dbgStack

// Numeric Constant
addConstant hungry number 0
addConstant content number 1
addConstant full number 2
addConstant dead number -1
// setToConstant -- doesn't work!'
addProp state number 0
prop character.state setToConstant hungry