1. Dislike of remainder(). Was: Re: No xor!!!
- Posted by "Carl R. White" <C.R.White at SCM.BRAD.AC.UK> Oct 27, 1998
- 391 views
On Tue, 27 Oct 1998, Bown, John wrote: > I particularly dislike the remainder() function and would love to see an > in-built 'mod' function ala > > a = 9 mod 4 -- instead of a = remainder(9,4) > > Comparative operators ( >=, != etc ) should really be extended, in the > same spirit, to cover all types without having to use the compare() > function, ala > > a = "Alfred" > b = "George" > if ( a < b ) .... I've been fiddling with David Cuny's preprocessor [I have this thing about David's code it seems :)] so that infix functions (i.e. 3 + 4 rather than +(3,4)) are possible. I've also tried to introduce some overloading capability. Unfortunately, I've not had the spare time recently. Anyway, here's some provisional syntax: function infix is_the_same_as(object left, object right) return compare({a}, {b})=0 end function sequence S atom A S = {4,2} A = s[1]*2 if {A,2} is_the_same_as S then -- ooh, shiny! :) -- do something end if I haven't decided whether it's feasible to use symbols (hence overloading them) yet. Another example: function "="(sequence left, sequence right) return compare(left, right)=0 end function sequence S atom A S = {4,2} A = s[1]*2 if {A,2} = S then --and again... -- do something end if But overloading "=" in this way breaks existing code: In Euphoria {4,2}={4,2} => {1,1} or {True, True}, not just True. I think I prefer the former at the moment... -- Carl R White -- Final Year Computer Science at the University of Bradford E-mail...: cyrek- at -bigfoot.com -- Remove the hyphens before mailing. Ta :) URL......: http://www.bigfoot.com/~cyrek/ Ykk rnyllaqur rgiokc cea nyemdok ymc giququezka caysgr -- B.Q.Vgesa