4 ms·
It isn't. Common Lisp and Scheme can do this as well and I like the look of predicate functions like "list?" or "number?": (list? object) (number? 1)
by aerique 13y ago
It isn't.
Common Lisp and Scheme can do this as well and I like the look of predicate functions like "list?" or "number?":
(list? object)
(number? 1) => returns true
(number? "abc") => returns false
It isn't really necessary for a language to support this, but it is a nice detail if one preferred such a style.
I think the custom is to use "!" in functions with side-effects.
- Someone 13y agoMore precisely, "functions that modify their arguments". For example, append(list,value) returns a new list; append!(list,value) modifies at least one of its arguments, typically, its first argument, but it could be another or multiple ones. By the way, all of these are conventions. The language doesn't require you to use the punctuation (http://opendylan.org/documentation/intro-dylan/expressions-variables.html http://opendylan.org/documentation/intro-dylan/expressions-v...). The conventions grow on you soon, though (I never really wrote anything in lisp or dylan, but still would like to see more flexibility in allowed characters in names) Functions that have side effects on non-arguments should be very rare, and don't use a naming convention (see for example http://opendylan.org/documentation/library-reference/common-dylan/simple-random.html http://opendylan.org/documentation/library-reference/common-...)