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

[REBOL] Re: percent! - new datatype request

From: joel:neely:fedex at: 16-Jun-2002 16:22

Hi to all who've been following/participating in this thread. One or two additional random thoughts have been rolling around in my head, so I thought I'd evict them! ;-) Percentage expressions ------------ ----------- I haven't heard any other comment on the question of whether decimal! values have a pre-existing meaning when used within LAYOUT blocks. If not, here's a potential compromise that I'd be interested in feedback on. I suspect that it would be easier to make a slight modification to the lexical rules for LOAD than to implement an entire new data type. (Notice I'm up to 2 assumptions now!) How about adding #"%" as a valid suffix to any numeric datum, with the meaning of "left shift the decimal point by 2 and yield a decimal! value" ? With this lexical tweak in place, 1% would represent the same value as 0.01 3.5% 0.035 100% 1.0 and so on. This would allow those who wished to represent factors in REBOL source (or input, or files, ...) as percentages to get the notational convenience, but would (my guess) not take nearly so long or as much work as a complete new datatype. For those whose specific interest is in resizing/scaling within View, I'd still wonder if decimal! scaling factors or some other dialect enhancement wouldn't be just as convenient. Other priorities ----- ---------- While thinking about how this compares with other things that I know have been on the table for some time, I remembered another issue that has disappeared from the radar scope -- formatting for output. Every language I use for real programming offers some way to control the way in which internal values are converted to strings for output -- except REBOL. Such capabilities include: - left- or right-padding or truncating strings to fixed width, - padding numeric values to specified lengths, with either zero or blank left-padding, - fixing total length and number of fractional digits for floating-point values, - collecting a series of expressions/values into a single string, with appropriate formatting for each. I recall some discussion quite a while back about this issue -- specifically about exposing some way to get at the underlying printf mechanism, as REBOL is implemented in c -- and the reply from Sterling (on or about 19 Sep 2000 16:40:32)
> A quick comment: > I understand what you're asking for and I personally think that > it is important as well but remember that "quick-and-dirty today" > often equals "major legacy problem" tomorrow. I bet a lot of > bloat in existing software can be attributed to this type of thing. > Those are some footsteps that we would rather not follow and I > think you don't want us headed that way either. > > I believe Carl already has in mind how he wants to solve these > types of formatting issues within REBOL. I don't know when it'll > happen though. >
In the intervening 175% of a year, we've had numerous discussions about how to format data for output, with decimal formatting being one of the most common/recent (including the issue of reliably rounding decimal values to a specified precision). Yet we still don't have a standard means of doing this common programming operation in REBOL. Let me add that to my things-that-keep-coming-up list that I'd like to see addressed before we start inventing new things to ask for (including my lexical compromise idea above!) -jn- -- ; Joel Neely joeldotneelyatfedexdotcom REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] { | e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]