Re: GIML ~ function return type(s)
"Buday, Gergely Istvan" <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <89AE2DBAB3A9E943A358F9780F266AC37E93F4@budgw09a.ww300.siemens.net> |
> hello all, > > very new to SML. i have a question about functions, can they > have multiple > result types? > > - fun torque (h::t) : int = 100 > | torque (h::t) : string = "100"; > > something like the above. is that possible or just a bad > idea? if it is bad, > could someone explain why this is restricted? I mainly have college > experience, with c/c++, and overloading of functions is supported. No, this is not allowed. What you can do is to define a sum type: datatype trq = INT of int | STRING of string fun torque (...) = INT 100 | torque (...) = STRING "100" I hope this helps. - Gergely ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642