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

World: r3wp

[Core] Discuss core issues

Ladislav
11-Nov-2011
[2608]
I want to share with you an "interoperability problem" I encountered. 
In Windows (at least in not too old versions) there are two versions 
of string-handling functions:

- ANSI (in fact using a codepage for latin charset)
- widechar (in fact UNICODE, restricted to 16 bits, I think)


It looks, that Apple OS X "prefers" to use decomposed UNICODE, also 
known as UTF-8MAC, I guess. That means, that it e.g. for a Robert's 
file it generates a filename looking (in a transcription) as follows:

%"Mu^(combining-umlaut)nch.r"

As far as the UNICODE goes, this is canonically equivalent to

%"M^(u-with-umlaut)nch.r"

, but:


- Windows don't consider these file names equivalent, i.e. you can 
have both in one directory

- When using the former, the ANSI versions of Windows system functions 
"translate" the name to: %"Mu^(umlaut)nch.r"

-- the %"Mu^(umlaut)nch.r" is a third file name, distinct from both 
of the above, so, if the R2 reads it in a directory, it is unable 
to open it
Gabriele
12-Nov-2011
[2609]
Linux also would not consider them equivalent. I understand why Mac 
OS is always canonicizing file names, but, they chose the most stupid 
way to do it, and it's a pain in the ass most of the time. In the 
end, I prefer Linux where you can end up with two files named in 
a way that looks exactly the same, but that has a file system that 
behaves in a predictable way.
amacleod
15-Nov-2011
[2610]
why does this not work:


unless any [exists? file1 exists? file2 exists? file3][print "missing 
file"]

but this does: 



 if any [not exists? file1 not exists? file2 not exists? file3][print 
 "missing file"]
Henrik
15-Nov-2011
[2611]
you would need an ALL instead of ANY in the first one, if it is to 
behave like the bottom one.
amacleod
15-Nov-2011
[2612]
right.....
amacleod
30-Nov-2011
[2613]
I'm trying to reach a time server but having trouble.

I can get a time from my rebol based time server on my server with 
"read daytime://myserver.com"

but if I use it for any of the well known online servers I get :
>> read daytime://time-b.nist.gov
== ""
>> read daytime://nist1-ny.ustiming.org
== ""


sometimes it seems to work but more often than not I get an empty 
string
BrianH
30-Nov-2011
[2614]
There are a few different time protocols, and the standard time servers 
don't tend to run the daytime protocol. They usually run NTP.
Pavel
30-Nov-2011
[2615x2]
2 amacleod: time protocol is not very accurate, the same levely of 
accuracy you can get by reading any HTML size and distile the time 
from HTML header. OTOH NTP protocol is able to get milisecond accuracy 
but by quite difficult handshake and as far as I know not yet written 
for rebol
size = site
amacleod
30-Nov-2011
[2617]
daytime://nist1.aol-va.symmetricom.com seems to work resonably well

I dont need to be too accurate just +- 5 seconds....


my server's time seems to be drifting. I've seen this before on an 
another computer...does a bad battery affect the time even if the 
power remains on?
BrianH
30-Nov-2011
[2618x2]
It might be better to enable your server's native time sync services. 
Windows, Linux and OSX all have such services, as do many more OSes.
The hardware clocks of many computers are rather inaccurate, though 
they're getting better.. They expect you to enabe the time sync services.
amacleod
30-Nov-2011
[2620]
It's enabled but does not sync as fast as the drift and I'm having 
trouble doing it manually...keep getting an error and I tried several 
time servers.
Henrik
7-Dec-2011
[2621]
if I have a file with url-encoded chars in it, what's the fastest 
way to decode them?
Dockimbel
7-Dec-2011
[2622]
dehex
Henrik
7-Dec-2011
[2623]
Thank you very much. I forgot that.
Henrik
10-Dec-2011
[2624]
what is the fastest way to find the number of digits in a number, 
if you want to use it to calculate the pixel width of the number 
for a table column? simply using:

length? form number

?
Geomol
10-Dec-2011
[2625x2]
My guess would be:

1 + to integer! log-10 number

, but that's slightly slower than yours, it seems.
Can your number both be integer and decimal?
Henrik
10-Dec-2011
[2627]
it's most likely to be a decimal
Geomol
10-Dec-2011
[2628]
Then mine won't work.
Henrik
10-Dec-2011
[2629]
I may have found another way without needing to work on the length. 
Thanks, anyway.
Geomol
10-Dec-2011
[2630]
:)
Ladislav
12-Dec-2011
[2631]
but that's slightly slower than yours, it seems
 - strange, here it looks much faster than length? form
Geomol
12-Dec-2011
[2632]
>> number: 1234                                       
== 1234
>> time [loop 1000000 [1 + to integer! log-10 number]]
== 0:00:00.293239
>> time [loop 1000000 [length? form number]]          
== 0:00:00.28022

On R2 version 2.7.7.2.5
Sunanda
12-Dec-2011
[2633]
I see the log-10 loop as around 18% faster under core 2.7.8.

So this optimisation depends, it seems, on specific machines and 
versions.
Kaj
12-Dec-2011
[2634]
It would depend on the relative speeds of the CPU and the FPU
Ashley
14-Dec-2011
[2635]
Ran code like the following against a 600MB file of 500,000+ lines:

	file: read/lines %log.csv
	foreach line file [
		remove/part line 1000
	]


and was surprised that the foreach loop was near instantaneous (I'd 
assumed 500,000+ removes would at least take a second or two). I'm 
not complaining, just curious. ;)
Geomol
14-Dec-2011
[2636]
Does it work? Or do you hit a 4GB boundary with some internal structures, 
so there is an error, you don't get out?
Ashley
14-Dec-2011
[2637]
It certainly worked (file size was 400MB not 600MB).
BrianH
14-Dec-2011
[2638]
R2 or R3? R3 can do removes from the head of the string as fast as 
it can from the tail - near instantaneously. I don't think that this 
is true for R2.
Ashley
15-Dec-2011
[2639]
R2.
Endo
15-Dec-2011
[2640]
I do something similar, generating 10'000 lines and writing to a 
file takes 5-6 seconds to complete on my Intel Core 2 Duo E7400 (2.8 
Ghz) 3GB RAM.

500'000 lines a bit too much but you read the whole file into memory 
so it is possible. Your PC is a good one as well I think.
Ashley
16-Dec-2011
[2641]
iCore 7 with 8GB RAM and a 256GB SSD ... work PC.
Endo
16-Dec-2011
[2642]
which means 10 times better than mine :) its normal to have that 
performance with 8GB RAM + SSD I think. file & block operations & 
foreach is fast on R2 in my experience.
GrahamC
16-Dec-2011
[2643]
Since Carl seems to have abandoned Rebol ...I wonder if this triggers 
the release of the source code held in escrow?
Sunanda
16-Dec-2011
[2644]
That would depend on what the escrow license says. Unless anyone 
here has signed a REBOL escrow source license, all we have is a vague 
description:
   http://www.rebol.com/faq.html#058
GrahamC
16-Dec-2011
[2645]
I wonder if Reichart  knows ... Qtask depends on Rebol
PeterWood
17-Dec-2011
[2646]
He may well know but I think that it is wishful thinking that the 
source may be released under an escrow agreement just because Carl 
has been quiet for a while.
Henrik
17-Dec-2011
[2647]
Since Carl seems to have abandoned Rebol

 - there is no evidence of that. A few weeks ago, it was stated here 
 that Carl was working on R3 again.
Gabriele
17-Dec-2011
[2648]
Qtask does not depend on any changes being made to REBOL.
Henrik
17-Dec-2011
[2649x2]
YY is a block of 4 decimals, which should be containing the same 
value, but it seems they are not the same to UNIQUE:

== [5.0 5.0 5.0 5.0] ; derived from a calculation
>> yy/1 == yy/2
== true
>> yy/1 == yy/3
== true
>> yy/1 == yy/4
== true
>> unique yy
== [5.0 5.0] ; huh?

>> zz: [5.0 5.0 5.0 5.0] ; typed directly in
>> unique zz
== [5.0]
Seems it's already been repported:

http://www.rebol.net/cgi-bin/rambo.r?id=4093&
Geomol
17-Dec-2011
[2651]
It's internal rounding in REBOL, is my guess. You can see it with 
R3:

>> to decimal! #{4013 FFFF FFFF FFFF}
== 5.0
>> to decimal! #{4014 0000 0000 0000}
== 5.0
>> to decimal! #{4014 0000 0000 0001} 
== 5.0

So decimals may look the same, even if they're not.
Henrik
17-Dec-2011
[2652]
it works in R3.
Geomol
17-Dec-2011
[2653x2]
In R3, you can try do a >to binary!< on the results from the calculation 
and see the difference.
In R2, you can do some rounding before calling unique.
Ladislav
17-Dec-2011
[2655x2]
In R3 also:

>> print mold/all to decimal! #{4013 FFFF FFFF FFFF}
4.9999999999999991
>> print mold/all to decimal! #{4014 0000 0000 0000}
5.0
>> print mold/all to decimal! #{4014 0000 0000 0001}
5.0000000000000009
see

    http://issue.cc/r3/1634
amacleod
18-Dec-2011
[2657]
I need to extract the data from an image file so it does not include 
the "64#" header and I just have the 64 bit encoding: 

64#{
/9j/4faARXhpZgAATU0AKgAAAAgABwEPAAIAAAAESFRDAAEQAAIAAAAIAAAAYgEa
AAUAAAABAAAAagEbAAUAAAABAAAAcgEoAAMAAAABAAIAAAITAAMAAAABAAEAAIdp
is3eIoxUdG7n/9k=
}


I just wnat the stuff between the quotes but as its a binary I can't 
seem to parse it or extract it with other methods like a text file.