World: r3wp
[Core] Discuss core issues
older newer | first last |
BrianH 31-Oct-2011 [2570x2] | Ladislav, Geomol, that same? :sine :sine/radians bug is already in CureCode here: http://issue.cc/r3/1559- please add your comments there. |
That issue is a really good reason to use ASSERT/type to validate your paths. | |
Ladislav 31-Oct-2011 [2572] | I see it as a minor issue. I would not be disappointed even if it stays as is. |
james_nak 31-Oct-2011 [2573] | Brian, aha, "Assert": another one of the newer, non-dictionary functions. Thanks for pointing those out to me the other day. I now have a list. |
BrianH 31-Oct-2011 [2574x2] | It is a potential security hole, but not more of one than assigning a function to an object field. It requires the same ASSERT/type call to screen for it. Still, it would be nice if it triggered an error on evaluation, especially since newbies would benefit from that error when they naively try to do a get-path for a function call instead of using APPLY or a direct call. |
James, ASSERT in R2 is not yet as good as ASSERT in R3. There are some limitations, most notably that you can't use ASSERT/type to validate a path. A proper native ASSERT is on the top of the list to add to R2 in the next version, whenever that comes. | |
james_nak 31-Oct-2011 [2576] | To be frank, it is most likely down the road before I ever use the new functions. I can tell just by perusing it that I would need to spend some time trying to understand what they do. But thanks for the input. |
BrianH 31-Oct-2011 [2577] | APPLY is a lot more useful in R2 than ASSERT; be sure to take a look at that one. |
james_nak 31-Oct-2011 [2578] | I will. Thanks. |
Henrik 2-Nov-2011 [2579x2] | Regarding my UNLESS TAIL? NEXT 'blah thing, perhaps this is more elegant: blah: min next blah back tail blah |
hmm... that does a comparison on the first value in the block instead of the index. is that useful? | |
Ladislav 2-Nov-2011 [2581] | That compares strings, (more general, since you can compare any strings, not just parts of the same head string starting at different positions) |
Henrik 2-Nov-2011 [2582] | yes, you are right. |
Geomol 9-Nov-2011 [2583] | Today's Moment of REBOL Zen: >> length? charset "" == 256 >> length? to binary! charset "" == 32 |
Oldes 9-Nov-2011 [2584] | 1 byte = 8 bits so 32 * 8 = 256bits:) |
Geomol 9-Nov-2011 [2585x3] | Bingo! But why? Does it make sense, that the length of a bitset! is reported as being 256? I guess, it does, as we can insert values from 0 to 255 into a bitset. |
Why isn't the length of a char one? >> length? #"a" ** Script Error: length? expected series argument Kinda related: it's funny, that a bitset! isn't a series, even if we can ask the length of it: >> series? charset "" == false | |
Or the length of a char could be 8, if we count in bits. But I feel, it would make more sense to give the length of a char as being 1. (I was working on a mezzanine version of string parsing, where skipping is much easier, if LENGTH? worked with chars too.) | |
Andreas 9-Nov-2011 [2588] | >> length? make bitset! 1024 == 1024 |
Geomol 9-Nov-2011 [2589] | Wow, didn't see that coming! Now, what does that mean? (Always more to learn.) |
Andreas 9-Nov-2011 [2590x2] | A bitset is just a collection of N bits which are either set or cleared. |
A charset is a 256-element bitset, as R2 recognises 256 distinct characters. | |
Geomol 9-Nov-2011 [2592] | I know the benefit of bitsets in parsing. For what use are other kinds of bitsets? |
Andreas 9-Nov-2011 [2593] | Why isn't the length of a char one? Because characters are no series datatype and therefore it does not make much sense to speak or their length. That's about the same as asking "Why isn't the lenght of an integer one?" or "Why isn't the length of a logic! one?" |
Geomol 9-Nov-2011 [2594] | Nah, I don't fully agree on that. Some code (as my string parse example) would benefit, if we could ask the length of a char. |
Andreas 9-Nov-2011 [2595] | And some code might benefit if we could ask the length of an integer. |
Geomol 9-Nov-2011 [2596] | :) |
Andreas 9-Nov-2011 [2597x2] | http://www.rebol.com/r3/docs/datatypes/bitset.html(for R3) http://www.rebol.net/wiki/Bitsets(also for R3) |
(Bitsets are vastly more useful in R3.) | |
Sunanda 9-Nov-2011 [2599] | <Other uses of bitsets> One use is conformity validation. eg: allowed-letters: charset [#"a" - #"e"] find allowed-letters "aaadddeeebbb" == true find allowed-letters "aaadddeeebbbx" == none |
Geomol 9-Nov-2011 [2600] | Yes, but that's the charset kind of bitset. I guess, other kinds of bitsets (other lengths than 256) can be used just to hold a bunch of flags or something. I haven't seen them used like that. |
BrianH 9-Nov-2011 [2601x2] | Bitsets are useful for intexes and certain kinds of parsing (LL first and follow sets, not just character sets). Other stuff too. |
intexes -> indexes | |
Gabriele 10-Nov-2011 [2603x2] | Geomol, because of Unicode, "charset kind of bitsets" need more than 256 bits. |
But, there are so many other ways to use them. For example, to implement a bloom filter: http://en.wikipedia.org/wiki/Bloom_filter | |
Oldes 10-Nov-2011 [2605] | I can imagine length? on char! value in unicode context - it could return number of bytes needed to store the char with the utf-8 encoding:) But I'm sure I can live without it. It would just add overheat to the length! action. |
Geomol 10-Nov-2011 [2606] | It probably won't add overhead to length?, because that function already works with different datatypes, and char! is just another one in the switch already there. |
BrianH 10-Nov-2011 [2607] | Oldes, the char! type in R3 refers to a Unicode codepoint, not a character. So, length still doesn't apply. |
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. | |
older newer | first last |