s |
focus search bar ( enter to select, ▲ / ▼ to change selection) |
g e |
go to examples |
g m |
go to modules |
g o |
go to overview |
g r |
go to reference |
h |
toggle this help ( esc also exits) |
#bake
#bake <procedure>(<type-variable> = <type>)
- generate a compiled function with predefined values for type variables. 1
// from: https://youtu.be/BwqeFrlSpuI?t=2325
named_bake_test :: (a1: $A, a2: A, b1: $B, b2: B) -> A,B {
a_sum := a1 + a2;
b_product := b1 * b2;
return a_sum, b_product;
}
nbt :: #bake named_bake_test(A = float, B = int);
// specify the names in any order:
// nbt :: #bake named_bake_test(B = int, A = float);
sum, product := nbt(1, 2, 3, 4); // 3.000000, 12
// from: https://youtu.be/BwqeFrlSpuI?t=2444
internal :: (x: u16) {
y : $SomeType = x;
printf("internal: y is %d\n", y);
}
baked := #bake internal(SomeType = u64);
baked (6000);
// won't work to call it directly:
// internal(5);
I can do a thing called ‘bake’, where I use this #bake
directive to generate a compiled function. This doesn’t happen at runtime, this is a thing that happens at compile time only, because we’re a compiled language.
“Polymorphic Procedures, part 1” YouTube, uploaded by Jonathan Blow, Apr 1, 2015, https://youtu.be/BwqeFrlSpuI?t=2170 ⮌
jailang
2019 pixeldroid
https://github.com/pixeldroid/jailang |
programming pages theme v0.5.21 (https://github.com/pixeldroid/programming-pages) |
s |
focus search bar ( enter to select, ▲ / ▼ to change selection) |
g e |
go to examples |
g m |
go to modules |
g o |
go to overview |
g r |
go to reference |
h |
toggle this help ( esc also exits) |