soolar
Member
Right now, you can create record literals in variable definitions in ASH, so this example code works like you'd expect (prints 'hello: world')
Unfortunately, you don't seem to be able to use them anywhere else, so the code below fails, saying it expected to find a ) but found a { instead.
I'm experimenting with reworking some stuff in ChIT atm to make it nicer to maintain and would love to be able to use the latter format for some things (mainly html tag related) to make the code a lot more readable. Seems like it shouldn't be too different to pass a literal to somewhere you have a definition for what you expect (a function parameter) vs somewhere else (a variable definition), so I'm cautiously hopeful that this isn't a big ask, and is instead just not something someone's wanted before.
EDIT: I should work on my reading comprehension, you CAN do this, it just requires you to specify the type of the aggregate in place. It would be nicer not to have to do that, but it's not a big deal.
Code:
void testFunction(string[string] example) {
foreach a,b in example {
print(a + ': ' + b);
}
}
string[string] var = { 'hello': 'world' };
testFunction(var);
Unfortunately, you don't seem to be able to use them anywhere else, so the code below fails, saying it expected to find a ) but found a { instead.
Code:
void testFunction(string[string] example) {
foreach a,b in example {
print(a + ': ' + b);
}
}
testFunction({ 'hello': 'world' });
I'm experimenting with reworking some stuff in ChIT atm to make it nicer to maintain and would love to be able to use the latter format for some things (mainly html tag related) to make the code a lot more readable. Seems like it shouldn't be too different to pass a literal to somewhere you have a definition for what you expect (a function parameter) vs somewhere else (a variable definition), so I'm cautiously hopeful that this isn't a big ask, and is instead just not something someone's wanted before.
EDIT: I should work on my reading comprehension, you CAN do this, it just requires you to specify the type of the aggregate in place. It would be nicer not to have to do that, but it's not a big deal.
Last edited: