Open aep opened 3 years ago
@jwerle
opinions on syntax for callsite assigns?
fn foh(int a, int b, char * other)
where a > 2
with b = 2 * a
{
}
fn foh(int a, int b, char * other)
where a > 2
where b = 2 * a
{
}
fn foh(int a, int b = 2 * a, char * other)
where a > 2
{
}
all of these are used by skipping the callsite arg:
fn main() {
foh(2, "boh");
}
and i feel like the last version makes that more obvious, although long expressions can look hard to read
fn foh(int a, int b = if constrained(typeof(vec::itema))) { vec::item(a) } else { u8 } , char * other)
where a > 2
{
}
fn foh(int a, int b, char * other)
where a > 2
with b = 2 * a
{
}
I like with
fn foh(int a, int b, char * other)
where a > 2
where b = 2 * a
{
}
but I also like where
...
fn foh(int a, int b = 2 * a, char * other)
where a > 2
{
}
This is very easy to understand
fn main() {
foh(2, "boh");
}
but I can see a reader having to come back to understand how it is used. Is there a keyword we could introduce in the argument signature the denotes the variable as a callsite argument?
fn foh(int a, int b = if constrained(typeof(vec::itema))) { vec::item(a) } else { u8 } , char * other)
where a > 2
{
}
oof! yeah that is hard to read ;)
Is there a keyword we could introduce in the argument signature the denotes the variable as a callsite argument?
yeah. probably we want that plus the full expression in the smt section, since its an smt expression, so...
fn foh(int a, callsite int b, char * other)
where a > 2
where b = 2 * a
{
}
or something. not sure about the keyword. this is too long
yeah something short and sweet
actually skipping arguments in the middle is weird anyway. I'm going to require callsite arguments be at the end, which makes them very similar to default arguments in other languages, so we're also going with that familiar syntax
yep that makes a lot more sense and we can avoid the extra keyword for the reader!
this doesn't work, but it should
the reason it's currently broken is actually generated tail arguments make argument ordering a mess. I want to get rid of auto-generated tail arguments anyway in favor of generic call-site assigns.