Earlier quoted context omitted.
Hahaha I doubt there's an English word left!!!
Rosemary and Oregano are free! Thyme is not.
Show HN: The Sage Programming Language
21–30 of 32 posts
Re: Show HN: The Sage Programming Language
#22FYI, Sage is also the name of a mathematical programming language: https://www.sagemath.org/
Re: Show HN: The Sage Programming Language
#23Re: Show HN: The Sage Programming Language
#24However I am confused if the enum's are structural or nominal. It seems necessary to state which enum a variant comes from, like `Direction of South` (for that matter it seems the same is true when constructing structs?). Can you cast enum values to a wider enum type? Or combine different enum values (e.g. through branching - the return of `match`) to construct a value of a wider enum?
Re: Show HN: The Sage Programming Language
#25One thing I like is exploring the structural typing. However I am confused if the enum's are structural or nominal. It seems necessary to state which enum a variant comes from, like `Direction of South` (for that matter it seems the same is true when constructing structs?). Can you cast enum values to a wider enum type? Or combine different enum values (e.g. through branching - the return of `match`) to construct a v…
``` enum Option {Some(T), Nothing}
// Create a value with an inline type that doesn't use the nominal `Option`
let opt1 = enum {Some(Int), Nothing} of Some(5);
// Define a second option value, which is assigned with the first
let opt2: Option = opt1;
// Print the result
println(opt2); ```
You can create a variant of an inline `enum` type, and then typecheck it against another structurally equal type if you so choose!
I hope this example properly illustrates how powerful the structural type-checking is with enums!
Re: Show HN: The Sage Programming Language
#26One thing I like is exploring the structural typing. However I am confused if the enum's are structural or nominal. It seems necessary to state which enum a variant comes from, like `Direction of South` (for that matter it seems the same is true when constructing structs?). Can you cast enum values to a wider enum type? Or combine different enum values (e.g. through branching - the return of `match`) to construct a v…
Hello, thanks for the great question! Yes, you do have to specify where a variant comes from, but it doesn't have to be nominal at all! Here's an example: ``` enum Option {Some(T), Nothing} // Create a value with an inline type that doesn't use the nominal `Option` let opt1 = enum {Some(Int), Nothing} of Some(5); // Define a second option value, which is assigned with the first let opt2: Option = opt1; // Print the r…
Re: Show HN: The Sage Programming Language
#27FYI, Sage is also the name of a mathematical programming language: https://www.sagemath.org/
Thank you!! Sage will eventually change its name (I just recently found out about this), but I haven't had time to come up with a good replacement name and make art + quippy sayings for it yet! :) I might just go with a completely made up word to avoid any trademarks entirely haha
Re: Show HN: The Sage Programming Language
#28Re: Show HN: The Sage Programming Language
#29Earlier quoted context omitted.
Hello, thanks for the great question! Yes, you do have to specify where a variant comes from, but it doesn't have to be nominal at all! Here's an example: ``` enum Option {Some(T), Nothing} // Create a value with an inline type that doesn't use the nominal `Option` let opt1 = enum {Some(Int), Nothing} of Some(5); // Define a second option value, which is assigned with the first let opt2: Option = opt1; // Print the r…
That's an interesting approach. So the variant name itself doesn't bear the type information but should be uniquely resolved in the type check time, right? It will be pretty much optimal unless you are doing metaprogramming stuffs.
Re: Show HN: The Sage Programming Language
#30One thing I like is exploring the structural typing. However I am confused if the enum's are structural or nominal. It seems necessary to state which enum a variant comes from, like `Direction of South` (for that matter it seems the same is true when constructing structs?). Can you cast enum values to a wider enum type? Or combine different enum values (e.g. through branching - the return of `match`) to construct a v…
Hello, thanks for the great question! Yes, you do have to specify where a variant comes from, but it doesn't have to be nominal at all! Here's an example: ``` enum Option {Some(T), Nothing} // Create a value with an inline type that doesn't use the nominal `Option` let opt1 = enum {Some(Int), Nothing} of Some(5); // Define a second option value, which is assigned with the first let opt2: Option = opt1; // Print the r…
``` enum Option {Some(T), Nothing};
let opt1 = enum {Some(Int)} of Some(5);
let opt2: Option = opt1; ```