World: r3wp
[Core] Discuss core issues
older newer | first last |
Graham 24-Mar-2008 [9703x3] | Hello <-extra space World |
I can understand spaces between words ... but at the end of a line?? | |
Anyone object to this ? reform [ "Hello" "world" newline "Again" ] => {Hello word^/Again} | |
Geomol 24-Mar-2008 [9706x2] | I bet, it's faster, the way it is. The internal rule is: Add a space after a non-newline. Don't add after a newline. |
May be annoying, but it's fast and small code. | |
Graham 24-Mar-2008 [9708x2] | I doubt that adding a new rule - don't add a space if next character is also whitespace will slow a native down much. |
Would it break anything to treat whitespace as special? | |
[unknown: 5] 24-Mar-2008 [9710x2] | or just rejoin: |
>> form rejoin ["hello" newline "there"] == "hello^/there" | |
Graham 24-Mar-2008 [9712x2] | rejoin evaluates the contents though which I don't want |
I'm only using reform here for clarity .. in reality I use 'form | |
Geomol 24-Mar-2008 [9714] | It's a very little annoyance, that you can work around. If REBOL were close to perfect, it would make sense to go into such things. There are much larger problems or things, that's nott finished with R3. (My opinion.) |
Graham 24-Mar-2008 [9715] | The reason I note this is that I was inserting an EPS into a block of words and then forming it. This adds an extra space on to the image data in the EPS and as the routine in the EPS to read the image data is white space sensitive, it dies. I have to do a replace/all { ^/} {^/} on it before I submit to the printer. |
[unknown: 5] 24-Mar-2008 [9716x2] | Graham reduce evaluates the contents also. |
Rejoin is even built off of reduce. | |
Oldes 27-Mar-2008 [9718x2] | is there better way how to do this?: >> trim/all/with form to binary! #"*" "#{}" == "2A" or >> copy/part skip form to binary! #"*" 2 2 == "2A" |
maybe: skip form to-hex 232 6 | |
Gabriele 27-Mar-2008 [9720] | >> enbase/base "*" 16 == "2A" |
btiffin 27-Mar-2008 [9721x3] | Or first to binary! 42.0.0 ? |
Never mind. :) | |
Sorry, just found out that to binary! on tuples moves binary and not formed binary. And wanted to try it. Not what you want in this case. | |
Fork 29-Mar-2008 [9724x7] | Greetings,my name is Brian (http://hostilefork.com). I am new to REBOL, and was introduced here by Reichart. I have a question I can't yet figure out. |
In REBOL if I do switch 'x [x [print "hello"]] | |
I get hello | |
If I do switch 'x [ to-lit-word x ["hello"]] | |
I also get hello | |
My question is the following: how do I get hello in the following situation | |
switch (What goes here?) ['x [print hello]] | |
btiffin 29-Mar-2008 [9731x2] | switch to lit-word! 'x ['x [print 'hello]] should work. It all comes down to knowing when values are evalutated. 'x outside a block is evaluated as the literal word x and is seen as the word! x ['x] inside a block is unevaluated until reduced so is in the block as an actual lit-word! 'x Clear as mud? Same for none. Outside a block (or anytime evaluated, none is a value none of type none! Inside a block it is simply a word! that hasn't been given a value. That case got me a few times if first [none] ... is true, as all word! data tests as true. if first reduce [none] is the false case. mold/all can be you friend when exploring this. |
And when I say "given a value", I mean an evaluated value. words in blocks have value, just not a variable substituion "value". Oh and I suck at explaining this. :) | |
Geomol 29-Mar-2008 [9733] | Yes, it comes to evaluation. In the second example, the block isn't evaluated, which can be seen with this: >> switch 'x probe [ to-lit-word x ["hello"]] [to-lit-word x ["hello"]] == "hello" If you try reducing the block, you get an error: >> switch 'x reduce [ to-lit-word x ["hello"]] ** Script Error: x has no value What you tried to do was this: >> switch 'x reduce [ to-lit-word 'x ["hello"]] == none You can get it to work AND get the block reduced with this (if that's what you want): >> switch 'x reduce [ 'x ["hello"]] == "hello" The thing is, putting a lit-word in a variable, and it's seen as a word, when evaluated (I think): >> a: to lit-word! "x" == 'x >> type? a == word! I hope, it makes it a little clearer. |
Gabriele 29-Mar-2008 [9734] | note, in your second example, the to-lit-word x is not really evaulated. |
RobertS 29-Mar-2008 [9735] | I would like to propose an addition for R3 When deguggin successive expressions it is a drag to keep shuffling down comment { until the suspect is reached Could we not use ;{ to be the equivalent pf comment { for code which has a REBOL header with a needs: that points to an R3 version? |
Anton 29-Mar-2008 [9736] | Almost there! I just use a multi-line string. :) { ... } |
RobertS 29-Mar-2008 [9737x3] | LOL But I need }; at the other end so that it nows which } is the outer brace or --{ }-- I like :{ }; because of the keys on QWERTY board ; - ) Ok we use {:-- --:} LOL |
typo :{ }: | |
or {: :} | |
BrianH 29-Mar-2008 [9740] | You can nest { and }, so it will know without some special mark. Use an editor with bracket matching and you can tell too. |
Graham 29-Mar-2008 [9741x2] | It would be nice if we can dynamically change the comment character. Just as some sql dialects allow you to change the termination character. |
This is for constructing stubs of other languages that use {, and then we don't have to escape them. | |
Fork 29-Mar-2008 [9743x3] | Geomol/btiffin/Gabriele -- thank you for your help. I'm actually trying to do something where the condition of the switch is inside a variable, and I had tried the to-lit-word and found it wasn't working. Apparently if I had done to-lit-word x' it would have worked, but my situation is: |
reduce [ y: 'x switch to-lit-word y ['x [print "hello"]] ] | |
In this case, is there a manipulation I can perform on y to make it match the condition? | |
BrianH 29-Mar-2008 [9746x4] | The comment character isn't { - comment is a function that takes one value and ignores it. |
(that was to Graham) | |
Fork, you can do either one of two things: y: to-lit-word 'x or switch y [x [print "hello"]] | |
You don't have to use a lit-word to make a word if you are not evaluating. On this line: y: 'x you are evaluating the lit-word and getting a word. On this line: switch y ['x [print "hello"]] you are not evaluating the lit-word 'x, so it stays a lit-word. | |
Fork 29-Mar-2008 [9750x3] | Thanks for the info BrianH... I am actually trying something very specific where for my purposes I can only change particular things. So my desire is: |
reduce [ y: 'x switch *** f(y)*** ['x [print "hello"]] ] | |
I need to substitute in *** f(y) *** something that is a function of y that will result in printing hello | |
older newer | first last |