Re: Ranged types

2011-12-21 Thread Tassilo Horn
Marek Kubica writes: Hi Marek, > Yeah, the problem that I see is that I have an additional set of > operators, r+, r- and friends, so every consumer has to be aware of my > numbers and use the proper operations, like the float-operators in > OCaml +. -. or the BigInteger stuff in Java. I'd like

Re: Ranged types

2011-12-21 Thread Linus Ericsson
2011/12/21 Marek Kubica > Hi, > > Thanks for your mail, glad to get ideas so fast :) > > On Wed, 21 Dec 2011 09:51:04 +0100 > Linus Ericsson wrote: > > > I would def a protocol CustomArithmetics and include the the > > nescessary methods for arithmetics, and then a deftype for each > > custom ar

Re: Ranged types

2011-12-21 Thread Marek Kubica
Hi, Wow, thanks for all that input :) It is always a pleasure to post on this list, to get such good advice. On Wed, 21 Dec 2011 09:51:31 +0100 Tassilo Horn wrote: > > I am idly thinging on how to create types with special restraints on > > them, like being only in the range 1-1000 or only even

Re: Ranged types

2011-12-21 Thread Marek Kubica
Hi, Thanks for your mail, glad to get ideas so fast :) On Wed, 21 Dec 2011 09:51:04 +0100 Linus Ericsson wrote: > I would def a protocol CustomArithmetics and include the the > nescessary methods for arithmetics, and then a deftype for each > custom arithmetics. It would be possible to extend t

Re: Ranged types

2011-12-21 Thread Tassilo Horn
Marek Kubica writes: > I am idly thinging on how to create types with special restraints on > them, like being only in the range 1-1000 or only even numbers etc and > all normal operations like + and - still being valid. + and - would have wrap-around semantics, I guess? > Anyone has an idea ho

Re: Ranged types

2011-12-21 Thread Linus Ericsson
Hi Marek! I would def a protocol CustomArithmetics and include the the nescessary methods for arithmetics, and then a deftype for each custom arithmetics. It would be possible to extend the protocol for Longs and Integers as well, if needed. If you would like to use the normal operator-names +,-

Ranged types

2011-12-20 Thread Marek Kubica
Hi, I am idly thinging on how to create types with special restraints on them, like being only in the range 1-1000 or only even numbers etc and all normal operations like + and - still being valid. Anyone has an idea how to implement that? In Python I'd subclass the number type and implement all