sttaft
func Search(Root : Tree; Desired_Value : Tree_Value)
-> optional Tree_Id is
var Identifier : optional Tree_Id := null;
for T => Root then Left(T) || Right(T)
while T not null concurrent loop
if Value(T) == Desired_Value then
// Found desired node,
// exit with its identifier
exit loop with Identifier => Key(T);
end if;
end loop;
return Identifier;
end func Search;
I actually don't use this feature much, because usually there is a key of some sort that determines which side of the tree is of interest. def Sum_Of_Squares(N : Int) -> Int:
return (for I in 1 .. N => <0> + I ** 2)
is legal ParaSail syntax. Parython uses a syntax similar to this, but with the "for loop" syntax re-arranged a bit to better match existing Python syntax.So the hope is for folks to look a bit beyond the surface syntax, and consider the underlying semantic model, which is hopefully where the more interesting issues reside in any case.
-Tuck
ParaSail is also designed to be simpler than many current languages in its basic module/type/object model. As part of that it eliminates re-assignable pointers, explicit storage allocation, explicit storage reclamation, garbage collection (it uses region-based storage management), run-time checking (it does it all at compile time), and run-time exceptions. Finally, there is no special syntax reserved for built-in types -- any appropriate type can support indexing (e.g. A[I]), slicing (e.g. A[1..5]), operators (+, -, <, >, +=, *=, ...), literals (e.g. X += 25), intervals (X..Y), aggregates (Map |= ["key1" => Value1, "key2" => Value2]), iterators (for each [Key=>Value] of Map concurrent loop ...), etc.