At 03:12 PM 7/29/2004 -0700, Tobin Fricke wrote:
In the Ptolemy expression language, a function is defined with
function(arg1:type1,arg2:type2, ...) body
What are the type signatures for non-simple types, like records or arrays?
For instance, how would I fix the definition of 'car':
cons = function(car, cdr) { car = car, cdr = cdr }
car = function(pair:{car,cdr}) pair.car
thanks,
Tobin
(NOTE: I wrote this reply before reading the further dialog,
but the reply might be useful anyway...)
Type designators in Ptolemy II are "prototypes".
Any expression can be a type designator.
To see this, bring up the expression evaluator
(File->New->Expression Evaluator) and type, for example:
>> double
0.0
"double" is actually just a constant that is defined
with value 0.0. It would be equivalent (albeit confusing) to
designate double types using the constant "PI". So, the type
of an array of doubles is:
{double}
or
{PI}
or
{0.0}
Similarly, a record type is:
{a=double, b=int}
That said, I don't understand your example above... I would
do something like this:
cons = function(car:double, cdr:{double}) arrayJoin({car}, cdr)
However, on quick glance, it looks like we don't have built-in
primitives like arrayJoin... This is an oversight... We need those...
Volunteer to create a set of such functions?
Edward
------------
Edward A. Lee, Professor
518 Cory Hall, UC Berkeley, Berkeley, CA 94720
phone: 510-642-0455, fax: 510-642-2739
[EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal
----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list. Please send administrative
mail for this list to: [EMAIL PROTECTED]