There is a case to be made for [Imperative] attributes for function definitions, e.g.:
[Imperative]
def : Number boolToNum( val : bool ) {
if ( val ) { return = 1;} else { return = 0; }
}
This could also clearly be inferred.
This is an assigned imperative block, with proposed dependency capture vars:
val = true;
a = [Imperative]( val ){
if ( val ) { return = 1;} else { return = 0; }
}
// a == 1
An assigned imperative block is thus a lot like an immediately evaluated anonymous function, in proposed syntax:
a = ([Imperative] lambda : Number ( val : bool ){ if ( val ) { return = 1;} else { return = 0; } )( false )
// a == 1
However, this form actually is more powerful, as the type declaration allows for replication to be performed:
a = ([Imperative] lambda : Number ( val : bool ){ if ( val ) { return = 1;} else { return = 0; } )( {false, true} )
// a == { 0, 1 }
IOW, the user can specify whether the the captured variables should be interpreted as a compound or singular value.
Perhaps, we can modify the Imperative block capture list to include a type annotation:
a = [Imperative]( val : bool ){ if ( val ) { return = 1;} else { return = 0; }
@lukechurch
There is a case to be made for
[Imperative]attributes for function definitions, e.g.:This could also clearly be inferred.
This is an assigned imperative block, with proposed dependency capture vars:
An assigned imperative block is thus a lot like an immediately evaluated anonymous function, in proposed syntax:
However, this form actually is more powerful, as the type declaration allows for replication to be performed:
IOW, the user can specify whether the the captured variables should be interpreted as a compound or singular value.
Perhaps, we can modify the
Imperativeblock capture list to include a type annotation:@lukechurch