User loginNavigation |
What's the type of an optional parameter?Functions in the language I'm building may have optional parameters, i.e. parameters that may or may not be supplied by the caller. In Common Lisp, unsupplied optional parameters receive NIL as their value. I want to avoid NIL, because I'd like to add an optional type system to the language later, and I don't want to have NIL as a value that's "in every type". So I've thought of making the type of optional parameters be like Haskell's Maybe: when the parameter is supplied with a value X, the function body receives it as Just X, and when the parameter is not supplied, it's Nothing (this means that for optional parameters, matching against Just or Nothing is always required in the function body). Thoughts? By Manuel J. Simoni at 2010-07-04 06:13 | LtU Forum | previous forum topic | next forum topic | other blogs | 5782 reads
|
Browse archives
Active forum topics |
Recent comments
2 weeks 2 days ago
42 weeks 3 days ago
42 weeks 4 days ago
42 weeks 4 days ago
1 year 12 weeks ago
1 year 16 weeks ago
1 year 18 weeks ago
1 year 18 weeks ago
1 year 21 weeks ago
1 year 25 weeks ago