r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3-OLD1]

Ammon
24-Mar-2009
[12230x3]
=D
I was going to put this on CureCode but when I go to the Add Ticket 
link it tells me to pick a project.  Project?  What Project and how 
do I pick it?
Oh, there it is.  I'm just blind...
Anton
24-Mar-2009
[12233x3]
I'm missing the --DO command line usage functionality from R2, here 
on linux.
I am missing --DO, but actually I miss -- even more.
I need to pass command line options in and be able to inspect them 
in system/options/args in user.r.
Henrik
24-Mar-2009
[12236x4]
we've talked about functions like NFOREACH before, regarding multiple 
blocks of different lengths, and it makes me think there is a need 
for handling numbers, where each digit is handled as a separate base.

It's tiresome to build counters and I feel there must be some common 
ground, som built in base counter could cover.
but this would not be normal number handling in that math isn't involved, 
only INC and DEC and some indicator of which digit is currently changing.
right now, I'm rebuilding the MAKE-TICKS function for the R3 GUI 
as I need more flexibility, and it would be greatly simplified and 
easier to understand with something like this.
Consider if we had a COUNTER! datatype. The counter would create 
a series of integers, each holding a separate base. The trick to 
COUNTER! is that it is a structure that holds more information than 
just the numbers, but also states, in the same way that a block holds 
an index or whether a port! is open or closed.

First the bad things:


- It can be complex and there are many things to consider. Many functions 
would be affected.

Now the good:


- This takes all the thinking out of building trivial counters and 
could greatly simplify it.
- It could be used as an any-base converter.
- No new functions to add specifically for it.

It should be possible to:

- Specify as many numbers per counter as we like.

- Each number would be within the limits of positive integers and 
each number would act as an integer! type.

- Extract information about which digit is currently counting or 
which number was last changed.
- Extract base information.
- Perform basic math (add/subtract).
- Perform base conversion for the entire counter.
- Perform base conversion between a counter and an integer.

A counter would hold four pieces of information:

- The base for each number
- The numbers themselves
- The last changed number as a one-based integer index

- The last numbers that were reset at last count as a block of one-based 
integer indexes

The nature of a counter:

- It would be a number!.
- It would not be a series!.

Specifying a counter:

- The above four pieces would be specified in order
- Each piece is separated by an exclamation mark
- Possible to skip pieces by leaving the field empty

- Syntax: !<base definition>!<number>!<last changed number>!<last 
reset numbers>
- Counter base alone: !12.14.16
- Counter base with number: !12.14.16!0.0.0

- Counter base with number and last changed number: !12.14.16!0.0.0!3

- Counter base with number and last changed number and last reset 
indexes: !12.14.16!0.0.0!3![2 1]
- Number without base: !!0.0.0

There's more, but it's a little much to write. :-)
Steeve
24-Mar-2009
[12240x3]
Henrik, what are the different usecases, you don't talk about it 
as much.

Can you fulfill a mezzanine which simulates his expected behavior 
?
Because, just by reading your specs, i can trully figure it.
(*i can't trully...)
Ammon, what about your tests on rich-text. Is that fast enough ?
Henrik
24-Mar-2009
[12243]
Steeve, I'm writing it up now. It's probably possible to do with 
a series of mezzanines, but it would not be very elegant.
Steeve
24-Mar-2009
[12244]
By elegant, you mean fast enough for your need :-)
Henrik
24-Mar-2009
[12245x2]
No, I mean being able to use ordinary math functions directly on 
the counter.
I'm changing my mind on not needing math and it not being a series. 
Sorry, if that seemed confusing.
Steeve
24-Mar-2009
[12247]
Don't worry, it seems confusing only because i'm stupid :)
Henrik
24-Mar-2009
[12248]
I just have a very clear example in MAKE-TICKS, where it would reduce 
about 10 hard to understand lines of code to 1 or 2 very clear lines 
of code.
Steeve
24-Mar-2009
[12249]
Just to replace 10 lines of code in one usecase ? You're assuming 
Rebol should behave as your own or what ? :-)
Henrik
24-Mar-2009
[12250]
I have encountered this problem before, where I just had to give 
up, because the problem became too complex to solve in a hurry. With 
the counter! datatype, it would not be a problem.
Steeve
24-Mar-2009
[12251]
If it can be used to maintain large index on any data structure efficiently, 
it could be usefull. I'm waiting for your code
Henrik
24-Mar-2009
[12252x2]
It'll be a while. Some things to think through first.
there is actually a built-in similarity to counter:

to-time 78
== 0:01:18

Just imagine any base instead of just !24.60.60
Steeve
24-Mar-2009
[12254]
I don't understand the meaning of the tuple. Is that just an indentifier 
?
Henrik
24-Mar-2009
[12255]
it's not a tuple. each number is a separate full integer.
Anton
24-Mar-2009
[12256]
This proposed datatype looks quite complex. Are you sure it's wise 
to add it to Rebol? Doesn't this just feed into lobbying for the 
user datatype? I might first implement your counter as mezzanine, 
solve the problem you have at hand, then maybe try to imagine how 
it could be specified using a user datatype...
Henrik
24-Mar-2009
[12257]
yes, Anton, I agree it's complex, but I'm not sure it's any more 
complex than object! or port!. A mezzanine would only partially solve 
the problem, but it would allow similar behavior.
Steeve
24-Mar-2009
[12258]
btw, i assume, it could be implemented as a scheme
Henrik
24-Mar-2009
[12259]
it probably can
Anton
24-Mar-2009
[12260]
Where is the current MAKE-TICKS source, by the way?
Henrik
24-Mar-2009
[12261]
Posting to you privately.
Pekr
24-Mar-2009
[12262x2]
I was looking for it too. What is this function supposed to do?
Is it timer related?
Henrik
24-Mar-2009
[12264]
no, it simply makes a shape block with tick lines for sliders, gradient 
bars and the rgb spectrum viewer. it will be used in more places 
than it currently is in use.
Anton
24-Mar-2009
[12265x2]
Yes, fairly recently we saw those slider demos with ruler marks on 
them.
.. which is where make-ticks was used.
Henrik
24-Mar-2009
[12267]
essentially MAKE-TICKS [3 1 2] would draw something like:

| . . : . . | . . : . . |
Steeve
24-Mar-2009
[12268]
Woooh, it means..., nothing to me :-)
Henrik
24-Mar-2009
[12269]
your clock on the wall probably has something similar. (if it's an 
analog clock) :-)
BrianH
24-Mar-2009
[12270]
Anton, the --do bug is known, cross-platform (not just Linux), and 
part of a half-dozen bugs that can be fixed by rewriting one function. 
It's the next R3 thing on my todo list, when I get the chance. I'm 
swamped with work at the moment.
Pekr
24-Mar-2009
[12271]
:-) I thought it is Braile letters :-)
Anton
24-Mar-2009
[12272]
BrianH, cool, that it's next on your todo list - glad you've noticed.
BrianH
24-Mar-2009
[12273]
User datatypes can't add new syntax.
Henrik
24-Mar-2009
[12274]
http://rebol.hmkdesign.dk/files/r3/gui/106.png

Make-ticks was used in the 5 sliders at the top.
BrianH
24-Mar-2009
[12275]
I've just been busy lately. Carl fixed/documented a lot of things 
in alpha 37 for me, but I'm in crunch time at work now. Soon.
Anton
24-Mar-2009
[12276]
Henrik, I advise not spending the energy lobbying for the new datatype. 
Just implement the "counter" algorithm as optimally as you can and 
move on.
Henrik
24-Mar-2009
[12277]
Sorry, I think there's too much in this to pass it up. I think this 
would be very useful.
Anton
24-Mar-2009
[12278]
Ok, sliders, rulers, analog clocks... anything else?
BrianH
24-Mar-2009
[12279]
Aside from the syntax, this could be done as a user-defined datatype. 
Or it could be done as an API.