World: r3wp
[Core] Discuss core issues
older newer | first last |
TomBon 27-Mar-2009 [13198] | trouble with double caret afer forming a string from block. print y: form [KBE RKH CSCD IDJ MNOV LCAPB CWCO ^DJA] KBE RKH CSCD IDJ MNOV LCAPB CWCO ^^DJA how can I avoid the double caret? form, mold or composing the string via foreach etc. doesn't work here. |
Chris 27-Mar-2009 [13199] | >> print y: form [KBE RKH CSCD IDJ MNOV LCAPB CWCO ^DJA] KBE RKH CSCD IDJ MNOV LCAPB CWCO ^DJA |
TomBon 27-Mar-2009 [13200] | sorry I mean a probe... -> probe y: form [KBE RKH CSCD IDJ MNOV LCAPB CWCO ^DJA] |
Chris 27-Mar-2009 [13201] | Any time the string is displayed literally (such as at the console, or mold/save) will you see the double caret. Internally it's a single caret. |
Steeve 27-Mar-2009 [13202] | there is no double caret in the string ^^ is only one char! |
Chris 27-Mar-2009 [13203] | You can - print replace/all mold this_string "^^^^" "^^" |
Steeve 27-Mar-2009 [13204] | As chris states, there is a difference between how rebol show some chars and how they are kept internally |
Chris 27-Mar-2009 [13205] | But there's no way other than a rewrite to get 'probe to display a single caret. |
Steeve 27-Mar-2009 [13206] | same behavior with tab, newline,... a tab is showed as "^-" but internally it's only one char! |
TomBon 27-Mar-2009 [13207] | ahh I see. I need this string to compose a url and get a error. thought by 'probe the second phantom caret was the failure. |
Chris 27-Mar-2009 [13208] | What is the error? |
TomBon 27-Mar-2009 [13209x2] | looks like rebol doesn't accept the caret with a url |
must be encoded | |
Chris 27-Mar-2009 [13211x3] | >> http://foo^bar == http://foo^bar >> to-string http://foo^bar == "http://foo^^bar" >> load to-string http://foo^bar == http://foo^bar |
I think it's 'net-utils/url-parser/parse-url that breaks it. | |
(this is used by the builtin schemes) | |
TomBon 27-Mar-2009 [13214x5] | yes, made a string and then to-url. this helps if the caret is hex-encoded %E5 |
will check for lower level open port... | |
chris, is your previous replace/all snippet working ? | |
ok, the parse needs "^^" "%E5" | |
thx, chris and steeve | |
Chris 28-Mar-2009 [13219] | Is there any string that 'to-time will return an error? |
Dockimbel 28-Mar-2009 [13220x2] | Seems that it never returns an error. |
But it should in this kind of input string : >> to-time "1:111:11" == 2:51:11 | |
Sunanda 28-Mar-2009 [13222x2] | R3 alphas will fail bad strings: >> to-time "" ** Script error: content too short (or just whitespace) >> to-time "x" ** Script error: cannot MAKE/TO time! from: "x" >> to-time "12:12" == 12:12 |
But Dockimbel's issue is unchanged in R3 | |
Dockimbel 28-Mar-2009 [13224] | So, a typo in a user input string could result in returning a wrong time! value without throwing an error. Looks like a bug or at least, a flaw IMO. |
Sunanda 28-Mar-2009 [13225x2] | REBOL has always had a policy of "normalising" times with >59 minutes. Even without the to-time and string: >> 1:111:11 == 2:51:11 |
Ditto with seconds: >> 1:0:5000 == 2:23:20 | |
Dockimbel 28-Mar-2009 [13227] | That looks dangerous to me, some typo can't be detected. |
Sunanda 28-Mar-2009 [13228] | Agreed! |
Henrik 28-Mar-2009 [13229x2] | interestingly, R3 returns: >> 1:0.5000 == 0:01:00.5 |
but the other example is the same | |
Sunanda 28-Mar-2009 [13231] | I think you may have a typo........My example was 1:0:5000 (two colons). I see identical behavior in R2 and R3 |
Henrik 28-Mar-2009 [13232] | you are right, sorry. |
Geomol 30-Mar-2009 [13233] | Where did the action PATH come from? Write in the console: ? path I can't see it documented anywhere. |
Oldes 30-Mar-2009 [13234x2] | I guess it should not be visible if it's not documented... some internal function probably. |
Ask on R3 chat so Carl can see it. | |
Chris 30-Mar-2009 [13236x2] | >> blk: [a b c d e] == [a b c d e] >> foo: [bar 5] == [bar 5] >> path blk foo/bar >> blk == [a b c d] >> foo/bar: 1 == 1 >> path blk foo/bar >> blk == [] >> foo == [bar 1] |
Returns an unset!, clears the block from given index... | |
Geomol 30-Mar-2009 [13238x2] | So, beside the unset! returned, PATH is like CLEAR AT ? |
Anyone using ALSO? | |
Steeve 30-Mar-2009 [13240] | everywhere |
Geomol 30-Mar-2009 [13241] | Can you give examples? |
Anton 30-Mar-2009 [13242] | The primary example use was in functions, to return the contents of a variable and also free the variable. eg, this: add-one: func [value][1 + also value value: none] replaces older code such as this: add-one: func [value][1 + first reduce [value value: none]] |
Geomol 30-Mar-2009 [13243] | Is that a good example? Why would you set value to none, if it's a number? It doesn't matter. |
Steeve 30-Mar-2009 [13244x2] | use cases: 1/ swaping a with b a: also b a: b 2/ in a function, returning a value after cleaning local vars func [x /local tmp][ tmp: a * 2 also tmp tmp: none ] |
error with swaping a: also b b: a | |
Geomol 30-Mar-2009 [13246x2] | Hm, a SWAP command could be a good idea, maybe. Or just do: set [a b] reduce [b a] About freeing local variables, why would you do that? Don't you call your function several times? You give garbage collector more to do this way. If it's often the case, that locals should be freed, then maybe we need a new function type, that does that? (I'm asking all this, because I never understood the reason for having ALSO.) |
When I think about it, much of this is based on assumption how memory is handled in REBOL. We don't really know, because it's not documented. When is it good to free a local, and when not? There may be something wrong, if this should be handled by the programmer (also when it's not documented). | |
older newer | first last |