At 
http://rosettacode.org/wiki/Icon%2BUnicon/Intro#Procedure_Parameter_Type_Casting
 
the following example is given:

procedure f1(i:integer:1,r:real,s:string,L:list,x:mycoercionproc)

Comments/queries:

(1) I can’t find any formal documentation of this feature. Is it defined
anywhere?

(2) Experimentation indicates that the only things allowed after the
“:” are data types (integer, real, string, list etc.). I have been 
unable to create any customised coercion function (as mycoercionproc in 
the example above) that the compiler will accept.

(3) In a case like

procedure f1(T:table)

what does “:table” actually do? You can convert a real or (sometimes) a
string to an integer, but can you convert anything to a table that isn’t 
already a table? In this case, the function of “:table” seems to be just 
type checking.

(4) If I’m right on (3), consider this example from the Unicon book (p39):

procedure complete(prefix, filenames)
   suspend match(prefix, p := !filenames) & p
end

This works equally well whether filenames is a list (as assumed in the
text), a table, or a set. But there is no way one can use the feature 
under discussion to check that it is one of these: anything like

procedure complete(prefix:string, filenames:list|table|set)

is rejected by the compiler.

However, in the absence of documentation I may be simply misled about
what this feature is supposed to do.

Thanks for help
Kim


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to