You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ketos=> (struct foo ((a string)))
foo
ketos=> (struct bar ((b foo)))
bar
ketos=> (new bar :b (new foo :a "fails"))
Traceback:
In main, lambda
In system function new
execution error: type error for field `b` of struct `bar`: expected foo; found struct: foo { a: "fails" }
ketos=> (struct baz ((b struct)))
baz
ketos=> (new baz :b (new foo :a "works"))
baz { b: foo { a: "works" } }
The error confused me for a while until I realized the type for all struct values is "struct". Could it allow you to specify a struct type for a field?
Also, the definition for bar was accepted, even though there is no such type foo - every attempt to create a bar will fail to typecheck!
The text was updated successfully, but these errors were encountered:
Yes, struct definitions are seriously half-assed. No doubt.
I've been kicking around different ideas for how to improve it, but I haven't yet arrived at a clear vision for a total re-design of the struct operator. Until I do, you can leave this issue open to remind me (and maybe to collect other ideas to improve struct definitions).
I tried to specify a struct name as a field type:
The error confused me for a while until I realized the type for all struct values is "struct". Could it allow you to specify a struct type for a field?
Also, the definition for
bar
was accepted, even though there is no such typefoo
- every attempt to create abar
will fail to typecheck!The text was updated successfully, but these errors were encountered: