World: r3wp
[Core] Discuss core issues
older newer | first last |
Terry 19-Apr-2007 [7632x2] | explain unexpected situations ;) |
I just don't get how it's even possible that out: "test" .. somehow different that "test" ?? | |
Ladislav 19-Apr-2007 [7634] | usually when you write: out: "test" send-page out mime , you expect, that the OUT string remains to be "test", don't you? |
Terry 19-Apr-2007 [7635] | yep |
Ladislav 19-Apr-2007 [7636] | then don't change it |
Terry 19-Apr-2007 [7637] | I don't want to change it.. it just doesn't work |
Ladislav 19-Apr-2007 [7638x2] | OK, here is how: |
send-page: func [data mime] [ data: copy data insert data rejoin ["HTTP/1.0 200 OK^/Content-type: " mime "^/^/"] write-io http-port data length? data ] | |
Terry 19-Apr-2007 [7640] | oh yeah.. |
Ladislav 19-Apr-2007 [7641] | this way you can make sure that the original DATA argument remains unaffected |
Terry 19-Apr-2007 [7642] | hmm, that doesn't work either |
Graham 19-Apr-2007 [7643] | try insert copy data rejoin ..blah ... |
Ladislav 19-Apr-2007 [7644] | :-) it does, you probably made more errors of this kind |
Graham 19-Apr-2007 [7645x2] | or, even send-page copy data mime |
rather than mutating, we say "altering" :) | |
Terry 19-Apr-2007 [7647x2] | actually it worked fine the original way.. problem was i set the out: "test" within tiny server's try block |
sorry, not try.. in it's ANY[] block | |
Graham 19-Apr-2007 [7649] | whatever |
Ladislav 19-Apr-2007 [7650] | :-) |
Terry 19-Apr-2007 [7651x2] | so.. any [ out: "test" send-page out mime] well.. out: "test" is any, isn't it ;) |
but thanks for the quick response | |
Graham 19-Apr-2007 [7653x2] | I like that ... have a "whatever [ .. ] " |
yes, so send-page never gets executed | |
Terry 19-Apr-2007 [7655] | hehe |
Graham 19-Apr-2007 [7656x2] | send-page also doesn't return anything |
you probably meant all [ out: "test" blah .. ] | |
Terry 19-Apr-2007 [7658x2] | here's another question.. |
if you have a block like so.. aaa: [bbb[ccc "string"]] do the 'words take up memory? is there a limit to the number of 'words in a block? | |
Sunanda 19-Apr-2007 [7660] | length? first system/words == 1245 aaa: [bbb[ccc "string"]] == [bbb [ccc "string"]] length? first system/words == 1248 Max words is around 8192 (varies by version). Note that 1000 or so are taken up when you start. |
Terry 19-Apr-2007 [7661] | hmm, so that's not very practical way of storing a large flat DB ? |
Graham 19-Apr-2007 [7662] | Ashley's rebdb is an in memory db |
Sunanda 19-Apr-2007 [7663] | That's *unique* words, not total words used You can have as many aaa's as you like in different contexts; it adds only 1 to system/words |
Terry 19-Apr-2007 [7664x3] | yeah.. i just need a simple hash table |
but i like the aaa/bbb/ccc path syntax | |
a dictionary , for example.. cat ["def of cat" ] dog ["def of dog"] run out of words real quick | |
Sunanda 19-Apr-2007 [7667] | But you may need to use strings or some other form of identifier -- REBOL words are rationed. |
Terry 19-Apr-2007 [7668x2] | yeah |
but then you lose the path syntax. | |
Sunanda 19-Apr-2007 [7670] | Use ordinals, then you can go up to maximum integer with path syntax: database/1/234/4454/655/3 Slight problem there: when you delete things you have to leave empty slots or change all numbers. |
Terry 19-Apr-2007 [7671] | given they would act as keys.. that would be more than a 'slight' problem |
Sunanda 19-Apr-2007 [7672] | There's always a design trade-off. I have various systems where real keys (usually strings) are mapped to surrogate keys (usually integers). It's a good compromise in many cases. |
Terry 19-Apr-2007 [7673] | What is THE best way to store a large hash table in memory like a dictionary, .. and access the data? |
Henrik 19-Apr-2007 [7674] | terry, about accessing data, there is a speed issue with doing so with using indexes with paths, so data/2 is much slower than second data or pick data 2. that should solve at least that aspect. |
Sunanda 19-Apr-2007 [7675] | Not sure there is one best way.....I have a structure that has 158,000 keys indexing 120,000 documents. All in memory. The index (when loaded) is nearly 6meg. The code uses nested tables, hashes, surrogate keys and a couple of other tricks devised for the purpose. It's worth playing with approaches. You can normally expect a ten fold improvement between initial ideas and later improvements. |
Terry 19-Apr-2007 [7676x5] | yeah, i see that just pokin around with some data now.. |
I take it your keys are string? | |
Just thinknig that even Carl's tiny web server, that loads the www content into a hash table would be a very fast server | |
Don't even need mod-rewrites.. just intercept the GET request and take it from there | |
I've been working with Apache and PHP quite a bit, and it just feels really bloated. | |
Oldes 19-Apr-2007 [7681] | Is there any reason why to write for example: [ b: make block! 100 ] instead of just [ b: copy [] ] ? |
older newer | first last |