Data types

DinoCode is dynamically typed. You don’t need to declare the type, the value defines it.

Is everything an object?#

No. Primitive types are supported that do not require memory management:

TypeDescriptionMemory CostDocumentation
IntegerWhole numbers.Insignificant (It is primitive)Numbers
FloatDecimal numbers.Insignificant (It is primitive)Numbers
BooleanTrue and false.Insignificant (It is primitive)Constants
NoneAbsence of value.Insignificant (It is primitive)Constants
StringText strings.Variable (Requires GC)Strings
ArrayOrdered collection of values.Variable (Requires GC)Arrays
BigIntLarge whole numbers.Variable (Requires GC)Numbers
ObjectKey-value structure.Variable (Requires GC)Objects
Memory Management and GC

DinoCode uses a Garbage Collector (GC) with the Mark and Sweep algorithm to manage dynamic memory (Strings, Arrays, BigInts, and Objects).

Constants#

DinoCode provides predefined constants for common values:

ConstantTypeDescriptionExample
trueBooleanTrue valueactive = true
falseBooleanFalse valueactive = false
noneNoneAbsence of valueresult = none
nanFloatNot a numbervalue = nan
infiFloatPositive infinityvalue = infi
-infiFloatNegative infinityvalue = -infi
print true
print false
print none
print nan
print infi
print -infi

Special numeric values#

DinoCode allows mathematical operations that result in NaN and Infinity. Although with distinctions that separate it from other languages.

a = 0 / 0          # NaN
b = 1 / 0          # Infinity
c = -1 / 0         # -Infinity

if a == nan
    print "It is non-numeric. Invalid operation"

if b == infi
    print "It is positive infinity"

if c == -infi
    print "It is negative infinity"
Comparison with other languages
  • In JavaScript NaN == NaN is false. In DinoCode it is true, which makes it easier to validate.
  • In JavaScript NaN can propagate without restrictions. In DinoCode, it is handled more strictly.

For example:

a = 0 / 0     # NaN
if a  # RuntimeError: Cannot use NaN in a condition
  print a

print a as float    # RuntimeError: Cannot convert NaN to finite values

list = [1 2 3]
print list[a]  # RuntimeError: Cannot use NaN as an index

for i in 1..a # RuntimeError: Cannot use NaN as a limit
  print i

Type checking and conversion#

Learn more
  • Consult Type to check the type of a value.
  • Consult Global functions to use int(), float(), str() or the as operator.