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

World: r3wp

[Core] Discuss core issues

MichaelB
15-Dec-2005
[2975x5]
this is from the blog-chat: 

I liked Ladislavs function and just extended it a little bit: maybe 
bind would be nice like that - one can bind only the words one wants 
to and also only the types one likes, unless using plain, then all 
words of the same spelling get bound

old-bind: :bind

bind: func append copy third :bind [
	/only only-words [block! any-word!]
    /plain
    /local pos rule item
][
	if copy [words: copy words]
		
	either only [
		if any-word? only-words [only-words: reduce [only-words]]
    	if any-word? known-word [known-word: bind? known-word]

     if plain [forall only-words [change only-words to word! only-words/1]]

		parse words rule: [
			any [
				pos:
				set item any-word! (
					if any [
                	    all [plain find only-words to word! item]
                	    find only-words item
                	][
						item: old-bind :item known-word
						change pos :item
					]
				) | into rule | skip
			]
		]	
	][
		old-bind words known-word
	]	
]

f: g: h: i: 1
bl: ['f g h i]
c: context [f: 2 g: 3 h: 'hello]

bind/only bl c [f 'h]
get-values: [
	get to-word first bl
	get to-word second bl
	get to-word third bl
	get to-word fourth bl
]
probe reduce get-values

bind/only/plain bl c [f 'h]
probe reduce get-values

bind bl 'system
probe reduce get-values

bind/only bl c 'g
probe reduce get-values
sorry - layout got a little bit destroyed :-(
the function has still some small problems: eg: doesn't return the 
newly bound block and might change with 'plain refinement the 'only-words 
block
I hope a more correct version of only 'bind-only - just to have not 
something too wrong lurcking around

bind-only: func [

    {Binds only selected words to a context. If taken 'lit'erally even 
    just words of the same kind.} 
    words [block!]
    known-word [any-word! object! port!]
    only-words [block! any-word!]
    /lit
    /local pos rule item
][
    if any-word? only-words [only-words: reduce [only-words]]
    if any-word? known-word [known-word: bind? known-word]
    unless lit [
        only-words: copy only-words 

        forall only-words [change only-words to word! only-words/1]
    ]
	
      parse words rule: [
		any [
			pos:
			set item any-word! (
				if any [
                    				find only-words to word! :item
                    				all [lit find only-words :item]
                			][
					item: bind :item known-word
					change pos :item
				]
			) | into rule | skip
		]
	]
    words
]
I find it useful - just used it. :-)
BrianH
16-Dec-2005
[2980]
I have a simple question (I hope): What types does the hash! type 
hash? I recall it hashing strings, but does it hash words and other 
types as well? I'm wondering for what key types it would be useful 
to use a hash! to store the records. If the key type isn't hashed, 
there is no benefit over using blocks.
Volker
16-Dec-2005
[2981]
IIRC it hashes a lot now. And a benchmark is easy, fill a big block, 
search, if it is linear its hashed.
Louis
17-Dec-2005
[2982]
Is there a special symbol in the REBOL language for the Indonesian 
rupiah? I need to make a script to convert funds from US$ to Indonesian 
Rupiah.
Geomol
17-Dec-2005
[2983]
Take a look:
for i 32 255 1 [prin to-char i]
Louis
17-Dec-2005
[2984]
Geomol, thanks. The rupiah symbol isn't there, but there is a symbol 
that will make a decent substitute.
Terry
25-Dec-2005
[2985]
What's up with ASYNC?
Pekr
26-Dec-2005
[2986]
Rebol's networking layer must be somehow broken, if we are not able 
to get properly working async core ;-)
Terry
27-Dec-2005
[2987]
Is there a Rebol webserver that can handle POST data, that actually 
works?
Pekr
27-Dec-2005
[2988x2]
Uniserve?
what is the problem with post? as for cgi, I use read-cgi as in newer 
cores ... works so far ...
Terry
27-Dec-2005
[2990x2]
Yeah, Uniserver is the only one.. but it doesn't Encap.
where do you put read-cgi in the forever loop?
Pekr
27-Dec-2005
[2992]
hmm, dunno, but look at the source, you can simply copy the code 
to your own purpose ...
Terry
27-Dec-2005
[2993]
the source of which?
Pekr
27-Dec-2005
[2994x3]
read-cgi ...
it distinguishes two types, get or post ...
it uses simple loop - read-io ....
Terry
27-Dec-2005
[2997x3]
Look.. here's  what I'm trying to build with Rebol   http://www.uniformserver.com/
 

a fully powered webserver you can take with you on a USB Stick or 
even your camera's flash drive.
even has .htaccess security
I'm just so tired monkey wrenching Rebol
Pekr
27-Dec-2005
[3000]
what is monkey wrenching?
Terry
27-Dec-2005
[3001]
trying to get things to work
Pekr
27-Dec-2005
[3002]
to get things work? you can create rebol server in one page script. 
That it is not complete solution like uniformserver? well, it is 
not .... if something is not available out of the box, you simply 
have to code it yourself ...
Terry
27-Dec-2005
[3003]
exactly.. like I've got nothihg better to do than build a webserver 
in Rebol that can handle POST data.l..
Ladislav
27-Dec-2005
[3004]
you must be kidding, aren't you?
Pekr
27-Dec-2005
[3005x3]
Ladislav, Terry is different then us - his motives are not to use 
rebol only. He is more pragmatic - while he likes rebol, he misses 
some already done solution in rebol land. He might be right, from 
his pov. His intention is to build some system, using existing components. 
The trouble is, that he can actually use rebol, but then he can easily 
find himself implementing specific details of server e.g., but his 
intention lays in some upper layers of architecture ....
I still think, that in his particular case though, implementing small 
web-server would be rather trivial task though. There are some examples 
available ...
more trouble comes with licensing of the server, if he want to encap 
it, and yet he wants to provide kind of cgi (plug-ins) to run rebol 
scripts - then he violates the license imo ...
Ladislav
27-Dec-2005
[3008x2]
 like I've got nothihg better to do than build a webserver in Rebol 
 that can handle POST data

 - I have seen nothing capable of convincing anybody such a webserver 
 was distributed as a mezzanine?
Moreover, there already are third party solutions to this specific 
problem as far as I know.
Pekr
27-Dec-2005
[3010x2]
I don't fully understand your mezzanine comment :-)
yes, at rebol.org, small webserver ... even one provided by Carl 
iirc ...
Ladislav
27-Dec-2005
[3012]
it is directly meant as a comment to "monkey wrenching REBOL"
Pekr
27-Dec-2005
[3013x4]
my experince, sometimes is, than rather then to incorporate thrid 
party technology, learning its tricks etc., I implement simpler (yet 
not so capable) solution myself ...
in that regard, I wanted to ask Ladislav, about security - is it 
possible to protect system words, even to not be unprotected? :-) 
Imagine rebol would use system/locale for things like system messages 
in order to be translatable, but then someone could change the strings, 
which could be big security risk (user answering to different question)
posted originally in rt qa group, I did not notice I am chatting 
there, sorry ...
what about kind of protect/with 'value 'key ?
Ladislav
27-Dec-2005
[3017]
you cannot protect mutable values, even if you protect the words. 
Is that an answer to your question?
Pekr
27-Dec-2005
[3018]
yes .... I thought so, but then I thought maybe there will be some 
way of how to do it :-)
Ladislav
27-Dec-2005
[3019]
only one - make a value you don't want to be changed immutable. The 
problem is, that REBOL does not have immutable strings, blocks, functions 
or objects.
Pekr
27-Dec-2005
[3020x2]
what about extending secure scheme? to allow e.g. pre-boot, post-boot 
changes etc.? hmm, not sure it has a solution in my particular case, 
e.g. that I would like to hae system/locale translated, but then 
blocked against the changes ...
just thinking loud, sorry if nonsenses :-)
Ladislav
27-Dec-2005
[3022]
the only solution to your problem is to make your values immutable. 
The trouble is, that REBOL does not have immutable datatypes you 
might need
Pekr
27-Dec-2005
[3023x2]
ok, thanks ...
but that would not solve my case, if RT would do system/locale immutable, 
then I would not be able to change it. I though about protection 
by some kind of key, e.g., but dunno if it might work. at first change 
the key would be provided, for unprotect, the key would be needed 
...