Bottom line, this test now works:
//
// SUMTYPESTRUCTURE.EPOCH
//
// Test of holding a sum-typed value in a structure member
//
type intorstring : integer | string
structure s :
intorstring alpha,
intorstring beta
operate : s param
{
check(param.alpha)
check(param.beta)
}
check : integer param
{
assert(param == 42)
}
check : string param
{
assert(param == "test")
}
entrypoint :
{
s foo = 42, "test"
s bar = "test", 42
s baz = 42, 42
s quux = "test", "test"
operate(foo)
operate(bar)
operate(baz)
operate(quux)
print("Pass")
}
Next up I'm going to give a shot at implementing a dynamic list structure using this functionality. Once that works I'll probably start on templates/generics to get the compiler to the point where I can implement much more interesting stuff without repeating boilerplate code... things like containers, and so on.
Should be interesting!
You're lucky we're no longer in the dark ages, or 'purist' programmers would strap you to a server and burn you alive.
Keep up the crazy stuff you are doing! I find it all very interesting.