alternate syntax for functions
Posted: Tue Apr 19, 2011 12:48 pm
Gentlemen
curently all the languages that i know support function syntax like
FunctionName then arguments f1(ar1,ar2) etc..
but would it not be interesting if function syntax could work like fill in the blanks too
for example
now calling becomes
so defination can now become
wont this make such a readable beautiful code.
i wish this feature be implemented in cobra with syntax being if user wants such functions
than "_" be used to join "(" as done above if you find it confusing to do like
think about other possibilities
one can finally write english sentences to formulate code.
or another atribute could be introduced as to what name user would like its function to have at the backend
function names can clearly explain their intent with no need for extra comments
Thanking_You
RIGHT_THEN
curently all the languages that i know support function syntax like
FunctionName then arguments f1(ar1,ar2) etc..
but would it not be interesting if function syntax could work like fill in the blanks too
for example
object Reset( object object_to_set, object value_to_set )
{
object_to_set = value_to_set;
return object_to_set;
}
now calling becomes
bool was_here = false ;
Reset(was_here,true);
but had it been like this
Reset_(was_here)_to_(true); //nice isnt it
so defination can now become
object Reset_(object object_to_set)_to_(object value_to_set)
{
object_to_set = value_to_set;
return object_to_set;
}
wont this make such a readable beautiful code.
i wish this feature be implemented in cobra with syntax being if user wants such functions
than "_" be used to join "(" as done above if you find it confusing to do like
object Reset(object object_to_set)to(object value_to_set)
their is nothing extraordinary about its design at the
back end cobra can still produce it like this by joining names
[SpecialFunctionDefinition(Reset_(object object_to_set)_to_(object value_to_set)]
object Reset_to(object object_to_set,object value_to_set)
{
object_to_set = value_to_set;
return object_to_set;
}
think about other possibilities
one can finally write english sentences to formulate code.
if_(array)_has_multiple_arrays_inside_it_return_(out that_array)_else_return_null ;
-----------------------its def can be-----------------
object if_(Array array)_has_multiple_arrays_inside_it_return_(out Array that_array)_else_return_null
{
that_array = null ;
var x = array.GetEnumerator();
if ( x.MoveNext )
{
var current_elmt = x.Current ;
if ( current_elmt is Array)
that_array = current_elmt ;
}
return that_array ;
}
Backend:-
[SpecialFunctionDefinition(if_(Array array)_has_multiple_arrays_inside_it_return_(out Array that_array)_else_return_null
)]
object if_has_multiple_arrays_inside_it_return_else_return_null(Array array,out Array that_array){
;
}
or another atribute could be introduced as to what name user would like its function to have at the backend
[SpecialFunctionDefinition(if_(Array array)_has_multiple_arrays_inside_it_return_(out Array that_array)_else_return_null
)]
[FunctionNameVisibleToBackendAs( if_Array_has_multiple_arrays_inside_it_return_Array_else_return_null )]
object if_Array_has_multiple_arrays_inside_it_return_Array_else_return_null(Array array, out Array that_array)
{
;
}
function names can clearly explain their intent with no need for extra comments
Thanking_You
RIGHT_THEN