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

World: r3wp

[!REBOL3-OLD1]

MattAnton
17-Oct-2008
[7467]
My friend Abe challenged me to write a simple recursive fibonacci 
sequence and on the 46th iteration the program quits because rebol 
can't do that calculation. I tried it on Linux rebview and rebol/core 
and on windows vista rebview even without running my script. The 
strangest thing is that rebol can add much larger numbers, but just 
not these. Does that make any sense? try the equation in a rebol 
terminal yourself and see what I'm talking about. Very strange.
Geomol
17-Oct-2008
[7468]
Max integer is

>> to-integer 2 ** 31 - 1
== 2147483647
>> 1134903170.0 + 1836311903.0
== 2971215073.0

We see, your result is larger.
Gregg
17-Oct-2008
[7469]
But why doesn't it coerce to decimal automatically, as it does for 
larger numbers? 

Wondering why I've never seen this.
MattAnton
17-Oct-2008
[7470]
Thanks Geomol. That makes perfect sense. Should I be using decimal! 
instead?
Geomol
17-Oct-2008
[7471x3]
Becuase of 32-bit.
>> to-integer #7fffffff
== 2147483647
>> to-integer #80000000
== -2147483648
If you use decimals, you can have larger numbers, before you loose 
precision.
Up near
>> 2 ** 49
== 562949953421312.0
>> 2 ** 50
== 1.12589990684262E+15
Gregg
17-Oct-2008
[7474]
Why was I sure REBOL coerced the result in this case? Hmmm.
Geomol
17-Oct-2008
[7475]
I don't know. :-)

I often forget the math rules in REBOL too and just have to check.
MattAnton
17-Oct-2008
[7476]
I just tried "1134903170 [decimal!] + 1836311903 [decimal!] and that 
didn't work either... how can I get througth the "addition" barrier?
BrianH
17-Oct-2008
[7477x2]
People use integer! rather than decimal! because they don't want 
to lose precision at all, rather than eventually.
Matt, do this:
    (to-decimal 1134903170) + (to-decimal 1836311903)
or this:
    1134903170.0 + 1836311903.0
MattAnton
17-Oct-2008
[7479]
Thanks, now my script should work perfectly.
Geomol
17-Oct-2008
[7480]
If you write a number without a decimal point, it's an integer datatype. 
With a decimal point, it's a decimal datatype. You can use either 
in many functions:

>> for i 1 2 1 [print i] 
1
2
>> for i 1.0 2.0 1.0 [print i]
1.0
2.0
MattAnton
17-Oct-2008
[7481x2]
Rebol[]

fibonacci: func [{Makes a list of fibonacci numbers and stores them
	to a block called fibonacci-block.} loops [integer!] {Number of 
	iterations to run}
	] [
	fibonacci-block: [0.0 1.0]
	count: 0
	loop loops [
		addend-1: index? back back tail fibonacci-block
		addend-2: index? back tail fibonacci-block
		new: fibonacci-block/(addend-1) + fibonacci-block/(addend-2)
		append fibonacci-block new
		count: count + 1
		print count
		print new
		]
	Print fibonacci-block
	write %fibonacci.txt fibonacci-block
	unset fibonacci-block
	halt
	]
Print "Type fibonacci [# of loops] to make fibonacci-block."
halt
Thanks to all all of you my script works perfectly now. :-)
Geomol
17-Oct-2008
[7483]
:-)
PeterWood
18-Oct-2008
[7484x2]
In the DocBase page for GUI_Panels, Carl wrote


A group has no backdrop or border and arranges horizontally by default.


I feel this is ambiguous; do groups have no backdrop or border ever 
or only by default?


I'd like to edit the wiki to make this more clear but I can't tell 
 from the rest of the page whether a panel can have backdrops and 
borders. Can anybody with access to R3 clarify this?
By the way it looks a lot like a Java GridBag.
Chris
18-Oct-2008
[7486]
I'd imagine that's the distinction between Panels and Groups?
PeterWood
18-Oct-2008
[7487]
So you think that a Panel is an invisible container?
Anton
18-Oct-2008
[7488x2]
I think adding integers used to produce a decimal, when it overflowed. 
There were problems caused by this, and discussions followed, so 
it was changed to the current system.
Peter, I also think that, as Chris suggests, borders are designed 
to be invisible, while panels can be seen.  I don't see any reason 
why a border couldn't be restyled to be visible, though. It will 
be one of the first things I'll want to do - hacking if I have to.
PeterWood
18-Oct-2008
[7490]
From re-reading the Docbase page, it seems that both panels and groups 
may be visible as they have styles:


Panels are implemented with the panel and group styles. You will 
use these two styles together to create a wide range of layouts.


I don't think that I'll try to clarify the DocBase entry just yet 
though.
Anton
18-Oct-2008
[7491]
They /are/ styles, both.
Gabriele
18-Oct-2008
[7492x3]
Henrik, so far this looks exactly just like VID3, except that there 
is no separation between look and feel.
Gregg, I think what you remember about coercing to decimal is that 
if you type a number greater than maxint it gets loaded as decimal.
>> type? 2147483647
== integer!
>> type? 2147483648
== decimal!
Pekr
18-Oct-2008
[7495x2]
Gabriele - your desing used and combined multiple gobs. What we can 
see so far is the one gob design, plus gob style face being placed 
upon it. If we use only one draw block for various states, I wonder 
how do we do conditional drawing in one single draw blog - e.g. focused, 
vs normal state.
IMO instead of adding additional styles, we should be sure, that 
we can easily express such things as focusing, display of accelerator 
keys, etc.
PeterWood
18-Oct-2008
[7497]
Is it really one gob with a gob style face placed upon it? Isn't 
even something as simple as :
panel [
  button "Start"
  button "End"
]

at least 5 gobs?
Pekr
18-Oct-2008
[7498x2]
Peter - I am talking about one single style, not multiple styles 
being one gob.
From Henrik's code above, it seems we have only one draw block and 
various states (e.g. button up, down, over) are being handled only 
by parametrising via facets, but still one draw block. But is imo 
nicely simplified concept, BUT - it may not work for more complex 
styles. What if I conditionally want to draw (or not), if the style 
is focused, disabled, etc. Not everything can be imo expressed in 
one single draw block. That is why so far the removal of frames concept 
(having different draw blocks for various situations) was imo preliminary, 
but we will see ....
PeterWood
18-Oct-2008
[7500]
My guess is that the worst case would be that you have to use different 
styles and unhide and hide them as needed.
Henrik
18-Oct-2008
[7501]
Currently, PANEL produces a background along with a border. That's 
why there are a lot of rounded borders in the first screenshots. 
Due to a bug (?) in the layout engine, PANEL must have a draw block 
assigned that fills out the background with a neutral color.

GROUP behaves as follows:

- No background

- When not specifying elements in a group block, they layout vertically.

- When specifying elements in a group block, they layout horizontally.

- When specifying a number for the group block, each element lays 
out horizontally until the number is reached and then a new row is 
started.

Differences from VID3:


- There is no concept of rows and columns. Elements of uneven sizes 
will uncritically be laid out right next to eachother. I've not yet 
discussed with Carl whether this goes in or if there is a different 
solution. I've observed code for grid management in both GROUP and 
PANEL and a facet reading "grid: true", but it seems not to be working.
Graham
18-Oct-2008
[7502]
are you the only person testing AltVid?
Henrik
18-Oct-2008
[7503]
no
Graham
18-Oct-2008
[7504]
Just the only one talking :)
Henrik
18-Oct-2008
[7505]
So far :-)
GiuseppeC
18-Oct-2008
[7506]
A couple of articles I found interesting about the future of interpreted 
programming languages. 

http://weblog.infoworld.com/fatalexception/archives/2008/10/virtual_machine.html

http://weblog.infoworld.com/archives/emailPrint.jsp?R=printThis&A=/article/08/10/13/42TC-dynamic-futures_1.html

VM, JIT and access to other programming languages libraries is the 
future...
Maybe Rebol 4 ?
Henrik
19-Oct-2008
[7507]
There is no concept of rows and columns.
 <--- this was a bug and has been fixed.
Gabriele
19-Oct-2008
[7508]
Petr, most of the styles in VID3 use just one draw block. Also when 
using multiple gobs, eg. in a scroller, they have one draw block 
each too, and state is just changing the value of some words. Carl's 
version just limits this to a single draw block, without automatic 
resizing. Which, you're forced to do if you remove the distinction 
between feel and look (you're stuck with whatever gob structure was 
in the original style anyway without that distinction).
Pekr
20-Oct-2008
[7509]
Henrik - it seems your button design does not work for darker button 
variants, does it?
Henrik
20-Oct-2008
[7510]
It's very difficult to produce anything useful with a darker color.
Pekr
20-Oct-2008
[7511]
maybe changing button text color to white will be needed in such 
cases, or white 1px outline of text, but not sure how would it turn 
out ...
Henrik
20-Oct-2008
[7512]
That would complicate the code a bit too much. We can only recommend 
that people don't use dark buttons. :-) It's easy for the user to 
adjust anyway.
Pekr
20-Oct-2008
[7513x3]
Henrik - you latest screenshot simply shows, that 'label should be 
antialiased imo ....
Carl's now describing a bit sizin model in following chapter - http://www.rebol.net/wiki/GUI_Panels
New VID related blog posted - http://www.rebol.net/r3blogs/0152.html
- GUI: Thin skins, thick skins, and in-between
BrianH
20-Oct-2008
[7516]
That Panels doc is a work in process.