Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: percent! - new datatype request

From: carl:cybercraft at: 11-Jun-2002 20:12

On 11-Jun-02, Joel Neely wrote: Hi Joel, Good to have you back. And see below...
> Carl Read wrote: >> I think we need it, but not so much because it'd be easier >> (perhaps) for programming, but because it's more descriptive. For >> instance, we know what this means... >> prompt-payment-discount: $5.25 >> but does this... >> prompt-payment-discount: 5.25 >> mean money or percent? >> If it was this though... >> prompt-payment-discount: 5.25% >> we would know. > That's what comments (or descriptive names) are for. > prompt-payment-discount-percent: 5.25 > prompt-payment-discount-factor: 1.0 - (5.25 * 0.01) > or > prompt-payment-discount: 0.0525 ;; 5 1/4 percent
Okay, not a good example, so you missed my point. (: Instead, compare this... [1.05 12.75 1.15 19.22] with this... [%1.05 $12.75 1.15 19.22%] The datatypes make the data descriptive, both to people and REBOL. VID's a good example of making use of this, where a number is treated as width, a pair as width and height, a string as text and so on. And because they're individual datatypes we don't have to remember a specific order they need to be in. This doesn't of course work for all cases as you're often going to need more than one of each datatype, but it's a very useful feature to have. So instead of something like this... button label "A button" width 100 depth 50 color 255.0.0 we can have this... button "A button" 100x50 255.0.0 I don't think new datatypes should be added willy-nilly, but percent is definately one that should be there. They wouldn't give it a button on nearly every calculator if it wasn't in very common use now, would they? -- Carl Read