Open ta0kira opened 11 months ago
In the generated C++, it would be better to provide direct access rather than dispatching a function call.
// Category_Signal.hpp
// Function instead of extern so that it can be lazily initialized.
BoxedValue Static_Signal_SIGTERM();
// Category_Signal.cpp
struct Category_Signal : public TypeCategory {
LazyInit<BoxedValue> Static_SIGTERM;
}
BoxedValue Static_Signal_SIGTERM() {
return CreateCategory_Signal().Static_SIGTERM.Get();
}
It's unclear how to handle initialization in C++ extensions, though.
Maybe add virtual BoxedValue Static_SIGTERM() const = 0;
to Category_Signal
so that ExtCategory_Signal
needs to define it, then call that in LazyInit
? That would be better than just allowing definition of BoxedValue Static_Signal_SIGTERM()
directly because it would ensure that the same value is always returned.
Also, call optimization will need to choose which way to access Static_SIGTERM
.
Static_SIGTERM // from category
parent.Static_SIGTERM // from type
parent->parent.Static_SIGTERM // from value
Static_Signal_SIGTERM() // everywhere else
I was thinking that we could just skip the leading _
(etc.) and allow an ambiguous parse, but then we'd need to handle it in at least 4 contexts:
return Foo:BAR
. (New ExpressionStart
?)return BAR
or return BAR?Baz
. (2nd new ExpressionStart
?)return BAR.foo()
. (TypeCall
?)_
, e.g., return BAR_1.foo()
. (2nd new ExpressionStart
?)Another option is to always require it to be qualified.
I guess it would also make sense to allow internal values for completeness.
concrete Foo {
immutable
@static Foo VALUE
}
define Foo {
VALUE <- Foo{ }
@static Foo DEFAULT
DEFAULT <- Foo{ }
}
Not having them will become a usability issue when trying to support C libraries and state machines.
They don't necessarily need to be numbered like the name indicates, they should be somewhat similar to
enum class
in C++ andenum
in Java.This effectively means that they need to be streamlined
@category
variables. Also, they don't need to be called "enum"s. Maybe@static
?Maybe something like this for syntax:
The leading
_
is for easier parsing.UPPER_SNAKE
would cause problems with unqualified calls, e.g., inVALUE.foo()
isVALUE
a poorly-named type or an@enum
?UPPER_SNAKE
as a convention, so it really just needs a leading character.Some questions:
#self
during init, but that might not work withProcedureContext
, since it assumes that in@type
scope the code will live in the@type
.@static<Int>
seems like anInt
value), but specifying the whole type implies that some other category can be used.@static
is also misleading. Maybe@enum
would mean that we could enumerate the instances if we wanted to but that we're not going to.Maybe any immutable type should be allowed, but it will have the containing type by convention?