World: r3wp
[!REBOL3]
older newer | first last |
BrianH 18-Nov-2010 [6207] | One thing will definitely be easier though: JSON and Javascript define that they have Unicode source, but don't have a way to specify the encoding (they are text standards, not binary). They can be handled easily in R3 once the source is converted to a string though, since that conversion will handle the encoding issues. In R2 you'd have to either stick to ASCII data or use Gabriele's text codecs and then parse the UTF-8. |
Andreas 18-Nov-2010 [6208] | And of course you'll have to work around map! being case-insensitive. |
Kaj 18-Nov-2010 [6209] | Hm, does that differ from hash!? I can do a find/case on a hash! |
BrianH 18-Nov-2010 [6210x2] | Yes and no. It depends on whether the source of the dataset is also case-insensitive. The JSON standard doesn't specify one way or the other. |
Kaj, map! is object-like, hash is series-like. | |
Kaj 18-Nov-2010 [6212x2] | That's a problem |
I'm using hashes to cache directory contents. They need to be case sensitive to support Unix file systems. Now I have a problem with porting to R3 | |
BrianH 18-Nov-2010 [6214] | Binary is treated case-sensitively. Convert the file names to binary. |
Kaj 18-Nov-2010 [6215] | Cool, thanks |
BrianH 18-Nov-2010 [6216] | The map! type is not a direct replacement for hash!, it is a different type that serves the standard purposes that hash! usually served in R2, where it was mostly used in the way that map! can be used now. As a related benefit, object! can also be used in ways that hash! used to be used: SELECT and APPEND work with object! and map!. |
Kaj 18-Nov-2010 [6217] | Yeah, that's good. I never understood why R2 objects can't be expanded |
BrianH 18-Nov-2010 [6218x2] | R3 objects can't have fields *removed* because that breaks binding, but maps can *because* you can't bind to them. Most of the differences between maps and objects are because of that difference. |
All R3 objects are now like R2's system/words. | |
Kaj 18-Nov-2010 [6220] | That makes them way more useful |
Andreas 18-Nov-2010 [6221x3] | Having to convert all non-binary map keys over to binary is still rather stupid, but well. |
Maybe we'll get #1315 (or an alternative) before too much harm is inflicted. | |
I consider not having a key/value datatype which can store external (non-REBOL) data using a sensible internal (REBOL) type a major annoyance. | |
Kaj 18-Nov-2010 [6224] | Agreed |
BrianH 19-Nov-2010 [6225x6] | REBOL is case-insensitive by default, everywhere any-string or any-word types are used. Maps are no exception. |
Case-insensitive key-value stores are not uncommon. And we do have a workaround. | |
#1494 fits in better with the rest of R3 than #1315. | |
It's not that big a deal to use binary keys for map! because most data is binary when it comes into R3, so it's just a matter of *not* converting it *from* binary. | |
Btw, in a comment to #1494 Andreas brings up the possiblilty of another map type with a different, case-sensitive hash function. That would be a possibility, whereas #1315 would not, not would #1437 where it was suggested that case-sensitivity be an option. | |
not would -> nor would | |
Oldes 19-Nov-2010 [6231] | +1 for possible case-sensitive hashes.. I need it quite often |
Henrik 19-Nov-2010 [6232] | +1 here too |
Sunanda 19-Nov-2010 [6233] | As Brian says, case sensitive map is easy to do with binary keys. Here's my implementation of such, for anyone who needs it today). Improvement suggestions are welcome! http://www.rebol.org/view-script.r?script=r3-rehash.r |
Oldes 19-Nov-2010 [6234x2] | The problem is, that using something like this will slow down the evaluation.. the reason why we were using hash! in R2 was the speed. |
Case sensitivnes is very common outside our REBOL world. | |
Sunanda 19-Nov-2010 [6236] | I've tried some timing tests..... r3-rehash seems around 10% faster than native R2 hashes on my test data. That does not remove the speed increase that an R3 native hash may have. But it does suggest that migrating from R2 hash to R3 rehash will not cost performance. |
Oldes 19-Nov-2010 [6237] | That's probably because R2 hashes all values but R3 just the keys. But good result anyway. |
Sunanda 19-Nov-2010 [6238x2] | That sounds a likely explanation, thanks. |
My timing tests were flawed.....R3-rehash is __significantly__ faster than R2 native hash. That is still true even if we remove the set-up time and just look at random retrieval. {Of course that is based on my random dataset....your's may vary] | |
Kaj 19-Nov-2010 [6240] | Thanks for testing. I'd been wondering about that for some time |
GrahamC 19-Nov-2010 [6241x3] | NIST has decreed that federal agencies must move from SHA1 to SHA2 after 2010. I found this JS implementation .. anyone able to convert JS to R3 code? |
http://sourceforge.net/projects/jssha/files/jsSHA/1.3/jsSHA-1.3.zip/download | |
There's also this SHA2 library written in Haskell http://davidmercer.nfshost.com/projects/shaskell/shaskell.html | |
PeterWood 19-Nov-2010 [6244] | From a quick look, it doesn't seem that it should be too hard to convert the JS to R3 on Big Endian systems. |
Andreas 19-Nov-2010 [6245] | which sha-2 do you need? |
GrahamC 19-Nov-2010 [6246x2] | It doesn't matter .. sha-256 is good |
Ideally we should have an encryption port so we can also compute SHA2 on large files as we can with R2 | |
Pekr 20-Nov-2010 [6248] | Whole functionality of encryption ports should be imo added into R3, if not already there ... |
Sunanda 25-Nov-2010 [6249] | Are there are practical differences between these two R3 ways of extending an object? obj: make object! [] extend obj 'a 1 bind/new 'b obj obj/b: 2 probe obj == make object! [ a: 1 b: 2 ] |
Steeve 25-Nov-2010 [6250] | Extend is a mezz, so that much be slower. And I always try to avoid GC overheads due to excessive usage of 'reduce Thats why I think bind/new is more capable especially, this form: >set bin/new 'b obj 2 instead of: >>bind/new 'b obj obj/b: 2 |
Andreas 25-Nov-2010 [6251x2] | Besides the readability/performance trade-off, things also start to differ when non-true? values are involved: obj: make object! [] extend obj 'a none extend obj 'b false set bind/new 'c obj none set bind/new 'd obj false print mold obj ==> make object! [ c: none d: false ] |
(Which probably is a bug in EXTEND.) | |
Steeve 25-Nov-2010 [6253x2] | Nice catch |
Hum... Seems not a bug, but deliberate. | |
Sunanda 25-Nov-2010 [6255] | EXTEND is a wrapper for APPEND....So are there any practical advantages in using BIND/NEW rather than APPEND ? append obj [c: 3] == make object! [ a: 1 b: 2 c: 3 ] I know right now there are some differences when messing with PROTECT/HIDE, but there are many CureCodes to go before we'll know if those differences are for real. |
BrianH 25-Nov-2010 [6256] | I like the SET BIND/new trick. There has already been code in the mezzanines where such a trick would come in handy, but it had never occurred to me. Thanks Steeve! |
older newer | first last |