Re: [pure-lang-users] null
Status: Beta
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-09-27 23:31:04
|
John Cowan wrote: > I agree in general, but I don't know why would you want an operator > beginning with '?'. You never know what creative uses programmers can find for these. :) One use I can imagine is as a kind of dereferencing (prefix or postfix) operator. E.g., here is how you can define yourself convenient abbreviations for the reference 'get' and 'put' functions: > postfix 9 ? ; > r::pointer? = get r if refp r; > let r = ref 99; > r?; 99 > infixr 0 := ; > r::pointer := x = put r x if refp r; > r := r?+1; 100 > r := r?+1; 101 A potential infix use would be as an abbreviation for if-then-else, e.g.: > infixr 0 ? ; > def x?y,z = if x then y else z; > foo x = x!=0 ? 1/abs x, 0; > show foo foo x = if x!=0 then 1/abs x else 0; > foo 99; foo 0; 0.0101010101010101 0 Turning ? into an identifier constituent in the way you recommended would pretty much preclude such perfectly legitimate uses. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |