World: r3wp
[Core] Discuss core issues
older newer | first last |
Geomol 24-May-2010 [16833x3] | Steeve, no, doesn't work with strings: >> switch s/1 ["A" [print "A"] "a" [print "a"]] == none s/1 is a char! And SWITCH won't find it with a string. |
Gregg, "consistent"? Ahh... ;) I was thinking about changing the string into a binary. What would you think FIRST used on a binary returns? I would expect a binary, but it's actually an integer. I sometimes have a hard time seeing the consistency in REBOL. But I know, it's hard to find the logic way in all this. So many datatypes. :) | |
Also changing s/1 to a string gives unwanted result: >> s == "aA" >> switch to string! s/1 ["A" [print "A"] "a" [print "a"]] A So I end up with getting the integer value of a char to make this work: >> switch to integer! s/1 [65 [print "A"] 97 [print "a"]] a Not so good, as I see it. | |
Steeve 24-May-2010 [16836x2] | Ah! it's probably impossible to convert a char! into a string!, so forget it... |
hmmm. I just realized that you asked for insensitive case | |
Geomol 24-May-2010 [16838x2] | Yes, I need to test on chars in a string, and #"a" should be different from #"A". |
The only way using SWITCH, I see, is to operate with ascii values, and that isn't good. | |
Steeve 24-May-2010 [16840] | well, just use parse instead, its mostly the same structure than a switch. parse/case s [ #"A" (do something) | #"a" (...) | ... ] |
Geomol 24-May-2010 [16841] | Yes, parse can be used. My motivation was thoughts about switch. It seems, it could be improved. |
Andreas 24-May-2010 [16842x4] | REBOL3 is pretty consistently case-ignorant in this regard: |
>> #"a" = #"A" == true | |
And the SWITCH behaviour is just consistent with that. | |
(R2 is more inconsistent in this regard, as #"a" = #"A" is false, but SWITCH behaves case-insensitively, as you described.) | |
PeterWood 25-May-2010 [16846] | >> #"a" == #"A" == false Perhaps SWITCH needs a /Strictly refinement? |
Gregg 25-May-2010 [16847x2] | SWITCH used to be a mezzanine, so you could easily patch it if you want. This is the old mezz source. switch: func [ [throw] value cases [block!] /default case ][ either value: select cases value [do value] [ either default [do case] [none]] ] |
I use SWITCH very rarely, but I don't know about others. | |
Izkata 25-May-2010 [16849] | /case would be more consistent with 'find, 'parse, and 'select than /strictly would |
Geomol 25-May-2010 [16850] | The char! datatype has many similarities to numbers. The following is from R3 and looks strange to me: >> var - 32 = var == true What variable is equal to it's original value, even if you subtract 32 from it? >> var: #"a" == #"a" >> var - 32 = var == true A bit strange. I would prefer SWITCH to distinguish between #"a" and #"A". |
Rebolek 25-May-2010 [16851] | >> (var - 32) = var == false |
Geomol 25-May-2010 [16852x2] | This can be even more complicated when talking UTF encoding. Hm, who knows how R3 do this... |
Rebolek, do it in R3. | |
Rebolek 25-May-2010 [16854x4] | I'm not sure what exactly [var - 32 = var |
Ah, ok, this was R2. | |
Yes, in R3, it's true. | |
I agree with you, this is strange. | |
Steeve 25-May-2010 [16858] | >> #"a" - 32 == #"A" >> #"a" - 32 == #"a" == false >> #"a" - 32 = #"a" == true it's ok to my mind |
PeterWood 25-May-2010 [16859] | Izkata: /strict could also striclty equal to numbers to give an alternative to : >> number: 1 == 1 >> switch number [1 [print 1] 1.0 [print 1.0]] 1 >> number: 1.0 == 1.0 >> switch number [1 [print 1] 1.0 [print 1.0]] 1 |
Gregg 25-May-2010 [16860] | I think the var - 32 scenario is fine as well. It's all about context, and by making it work the other way, you're just shifting the problem, not really solving it. That is, something becomes easier, but something else becomes harder. |
Geomol 26-May-2010 [16861] | Gregg, are you really sure, you mean this? As I see it, the life would be much easier, if "a" equals "A", but #"a" didn't equal #"A". As it is now, it's really problematic testing for different characters in a string using SWITCH. Cases where "a" and "A" should be handled as the same is ok, but cases where they should be different is the problem. If #"a" was made to not be the same as #"A", then both situations could be coped with easily. |
PeterWood 26-May-2010 [16862] | At the moment Switch is consistent with Equal?. Surely, it would be better to retain that consistency and have a /strict refinement for switch which perfomed consistently with strict-equal? ? |
Geomol 26-May-2010 [16863x2] | Peter, the equal thing is correct for R3, not R2, which we still get updates for now and then. |
In other words, SWITCH is not consistent with EQUAL in R2, when talking the char! datatype. | |
PeterWood 26-May-2010 [16865] | You are correct, I was mistaken about the R2 behaviour. |
Gregg 26-May-2010 [16866] | First, it should be consistent between R2 and R3 if at all possible. For SWITCH, I think the solution is to add a refinement if people think it's needed. If the new native SWITCH is still based on SELECT, adding a /CASE refinement shouldn't be hard. For the more general case of char case-sensitivity, we have ==/strict-equal? |
Maxim 26-May-2010 [16867] | I agree with Geomol here. many people see chars as a subsitute for string, even I once saw it like that, but I have come to realize that they shouldn't be. #"A" should not be equal to #"a". |
amacleod 26-May-2010 [16868x3] | I'm getting an error with send that neever got before... >> send [bebop-:-gmail-:-com] "hello" ** User Error: Server error: tcp 421 Cannot connect to SMTP server 173.236.30.114 (173.236.30.114:25), connect error 10060 ** Near: smtp-port: open [scheme: 'esmtp] either only |
I tried several different accounts but get the same error | |
It seems to be working again...don't know what was going on | |
Maxim 26-May-2010 [16871] | you know... it IS possible that Google has outages too ;-) |
amacleod 26-May-2010 [16872x2] | I was using versizon google and another host...all the same prob... |
verizon | |
Will 26-May-2010 [16874] | amacleod: the IP address 173.236.30.114 resolve to cx02.justhost.com , which may be your provider. does that correspond to your smtp server? |
amacleod 26-May-2010 [16875x2] | yes... |
actually it did not happen sending on gmail account as i can't (without Graham's fix anyway) | |
Will 26-May-2010 [16877x3] | did you try an authenticated connection? |
trace/net on | |
telnet 173.236.30.114 25 answers? | |
Graham 26-May-2010 [16880] | that error should be with your ISP's smtp server |
Terry 27-May-2010 [16881] | ie: [a ["one"] b ["two"] c ["three"]] Q: best way to remove b and it's block ["two"] ? |
Henrik 27-May-2010 [16882] | remove/part find ie 'b 2 |
older newer | first last |