Type system

28 views
Skip to first unread message

Curtis Stanford

unread,
Jun 12, 2012, 12:01:39 PM6/12/12
to loop...@googlegroups.com
I don't quite understand the description of the type system in the FAQ. I notice that in functions, the parameters have no types. Can you just pass anything in there? Is there any way to specify a contract with the caller that certain types are required?

Thanks

Dave Newton

unread,
Jun 12, 2012, 12:19:13 PM6/12/12
to loop...@googlegroups.com
On Tue, Jun 12, 2012 at 12:01 PM, Curtis Stanford <cur...@stanfordcomputing.com> wrote:
I don't quite understand the description of the type system in the FAQ. I notice that in functions, the parameters have no types. Can you just pass anything in there? Is there any way to specify a contract with the caller that certain types are required?

Guards [1] or pattern matching [2] would seem the natural choices.

Dave

Curtis Stanford

unread,
Jun 12, 2012, 12:27:02 PM6/12/12
to loop...@googlegroups.com
On Tuesday, June 12, 2012 10:19:13 AM UTC-6, Dave wrote:
On Tue, Jun 12, 2012 at 12:01 PM, Curtis Stanford wrote:
I don't quite understand the description of the type system in the FAQ. I notice that in functions, the parameters have no types. Can you just pass anything in there? Is there any way to specify a contract with the caller that certain types are required?

Guards [1] or pattern matching [2] would seem the natural choices.


I guess I'm a bit of a static typing snob, but it doesn't seem practical to pattern match all arguments to functions to check types. I guess it answers my question though in that types on function parameters are not enforced in any way by the type system. 

Dhanji R. Prasanna

unread,
Jun 12, 2012, 11:50:20 PM6/12/12
to loop...@googlegroups.com, cur...@stanfordcomputing.com
You can just use a wildcard matcher to raise an error, which is the same thing.
Reply all
Reply to author
Forward
0 new messages