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

World: r3wp

[Core] Discuss core issues

[unknown: 5]
24-Mar-2009
[13162x2]
;consider:

>> a: "123"
== "123"
>> b: a
== "123"
>> b
== "123"
>> a
== "123"
>> append a "4"
== "1234"
>> b
== "1234"
>> a == b
== true
Obviously, a and b are pointers to the same memory address that  
holds the string.
Geomol
24-Mar-2009
[13164]
You don't check, if they point to the same mem area with strict-equal, 
you use same? (or =?) for that:

>> a: "abc"
== "abc"
>> b: "abc"
== "abc"
>> a == b
== true
>> a =? b
== false


So it's not obvious, they point to same memory address, just because 
a == check returns true.
BrianH
24-Mar-2009
[13165]
There are bugs in strict-equal? in R2 as well.
Geomol
24-Mar-2009
[13166]
Can you give an example?
[unknown: 5]
24-Mar-2009
[13167]
Ah right John, thanks.
BrianH
24-Mar-2009
[13168x2]
Sorry, it is strict-not-equal? that has the bug:
>> strict-not-equal? 1 2
== false
STRICT-NOT-EQUAL? only checks types with integer! values. Use NOT 
STRICT-EQUAL? instead.
Geomol
24-Mar-2009
[13170x2]
ok
Something funny. (We had a long discussion about this in R3-alpha.):

>> 0.3 - 0.2 - 0.1 = 0.0
== false

This is also false in e.g. the C language.
BrianH
24-Mar-2009
[13172]
It's a floating point thing - 0.1 can't be represented exactly in 
IEE754 floats.
Geomol
24-Mar-2009
[13173]
yes
Oldes
24-Mar-2009
[13174x2]
>> $3.0 - $2.0 - $1.0
== $0
use money! datatype if you need precision
BrianH
24-Mar-2009
[13176x2]
Those aren't IEEE754 :)
Or you could use fixnums: integer! and a scale.
Geomol
24-Mar-2009
[13178x4]
In REBOL:
>> 0.1 + 0.1 + 0.1 = 0.3
== true


In C, this is not true. So REBOL tries to cope with this problem, 
but don't do it 100%.
In e.g. Python, my last test is also not true.
But Python is also a bit strange, it seems. From Python prompt:

>>> 0.1 + 0.1
0.20000000000000001
>>> 0.1 + 0.1 == 0.2
True
>>> 0.1 + 0.1 + 0.1
0.30000000000000004
>>> 0.1 + 0.1 + 0.1 == 0.3
False
Ah, maybe it's not so strange. C does the same.
Graham
24-Mar-2009
[13182x2]
anyone remember where the parse demos showed a calculator dialect 
?
just need simple arithmetic
Geomol
24-Mar-2009
[13184]
This? http://www.rebol.com/docs/core23/rebolcore-15.html#section-6
Graham
24-Mar-2009
[13185x2]
yes .. thanks
saves me a few mins writing my own !
Pekr
26-Mar-2009
[13187]
I was trying to help new guy on ML, and just would like to ask - 
why is there a difference in evaluation when printing a block, and 
printing first block?

>> colors: [red green blue]
== [red green blue]
>> print colors
255.0.0 0.255.0 0.0.255
>> print first colors
red

so 'first does not reduce the value, while print itself does?
Steeve
26-Mar-2009
[13188]
it doesn't come from print behavior
but, it's how reduce works
reduce first [red]
PeterWood
26-Mar-2009
[13189]
>> a: 1

== 1

>> type? a

== integer!

>> type? 'a
== word!

>> b: [a
]
== [a
]
>> type? first b

== word!

>> print a

1

>> print first b

a

>> print 'a

a
Sunanda
26-Mar-2009
[13190]
Help says print does an evaluate (presumably a reduce) if the value 
to print is a block....So it is documented behavior:
  http://www.rebol.com/docs/words/wprint.html
Pekr
26-Mar-2009
[13191]
ok, thanks ....
Janeks
27-Mar-2009
[13192]
Hi!
Does Rebol suport AUTH=NTLM in IMAP protocol?
Thanks in advance!
Pekr
27-Mar-2009
[13193x2]
I think not. In the past, Doc did some tests, but not sure ...
http://softinnov.org/rebol/ntlm.shtml
Janeks
27-Mar-2009
[13195x2]
Thanks Pekr - I already saw it, but I am thinking how to use them 
in case of IMAP.
Is it just like opening port?
Pekr
27-Mar-2009
[13197]
Don't know - never worked with it ...
TomBon
27-Mar-2009
[13198]
trouble with double caret afer forming a string from block.

print y: form [KBE RKH CSCD IDJ MNOV LCAPB CWCO ^DJA]
KBE RKH CSCD IDJ MNOV LCAPB CWCO ^^DJA

how can I avoid the double caret?

form, mold or composing the string via foreach etc. doesn't work 
here.
Chris
27-Mar-2009
[13199]
>> print y: form [KBE RKH CSCD IDJ MNOV LCAPB CWCO ^DJA]

KBE RKH CSCD IDJ MNOV LCAPB CWCO ^DJA
TomBon
27-Mar-2009
[13200]
sorry I mean a probe... -> probe y: form  [KBE RKH CSCD IDJ MNOV 
LCAPB CWCO ^DJA]
Chris
27-Mar-2009
[13201]
Any time the string is displayed literally (such as at the console, 
or mold/save) will you see the double caret.  Internally it's a single 
caret.
Steeve
27-Mar-2009
[13202]
there is no double caret in the string 
^^
 is only one char!
Chris
27-Mar-2009
[13203]
You can - print replace/all mold this_string "^^^^" "^^"
Steeve
27-Mar-2009
[13204]
As chris states, there is a difference between how rebol show some 
chars and how they are kept internally
Chris
27-Mar-2009
[13205]
But there's no way other than a rewrite to get 'probe to display 
a single caret.
Steeve
27-Mar-2009
[13206]
same behavior with tab, newline,...
a tab is showed as "^-" but internally it's only one char!
TomBon
27-Mar-2009
[13207]
ahh I see. I need this string to compose a url and get a error. thought 
by 'probe the second phantom caret was the failure.
Chris
27-Mar-2009
[13208]
What is the error?
TomBon
27-Mar-2009
[13209x2]
looks like rebol doesn't accept the caret with a url
must be encoded
Chris
27-Mar-2009
[13211]
>> http://foo^bar
== http://foo^bar
>> to-string http://foo^bar
== "http://foo^^bar"
>> load to-string http://foo^bar
== http://foo^bar