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

World: r3wp

[Core] Discuss core issues

BrianH
14-Mar-2009
[12956x3]
Gab, sorry, I thought you were talking about DocBase (as others were) 
rather than the parse proposals. The reason I mentioned the chat 
is because you keep bringing up the DO operation as if you are trying 
to convince us of its importance, but we all agree with you so it 
doesn't help. I was trying to point you to a forum where trying to 
convince someone about a parse proposal would have some effect.
As for the Parse Proposals wiki, I'm afraid it will need some cleaning 
down. I kept trying to tell Peta the rules Carl set up, but Peta 
kept ignoring them and going into great detail about parse theory 
and such. Half of the contents of that page are going to have to 
be moved to other pages, and I'm probably going to have to summarize 
the best of the proposals to Carl if we want to convince him to implement 
them.
You have a good point about the nforeach reduce thing, but I am not 
convinced that giving up the ability to generate the data in other 
functions is worth it. I usually don't like to see DO/next in mezzanine 
code anyway: DO/next is usually a sign of a function that doesn't 
work in a REBOL-like way and has too much overhead to use. However, 
I still want Carl to fix DO/next in R3 - it doesn't work at all at 
the moment, and there are some proposed functions that can't be implemented 
without it.
Gabriele
15-Mar-2009
[12959x2]
to me do/next is just a sign of a dialect :-)
maybe too many dialects is bad, but i personally think it's worth 
trying.
Chris
15-Mar-2009
[12961x2]
I have a 'case like function that uses 'do/next
Like case, but inverted (performs the block if the result is false). 
 It'd be easier to implement using [block block] or [paren block] 
pairs, but would not be as readable - imagine the same with 'case 
?
BrianH
15-Mar-2009
[12963]
Chris, that sounds like a good job for DO/next. It also sounds like 
a function that would be replaced by CASE [NOT ... when the code 
is being optimized. REBOL programmers can be pretty ruthless when 
it comes to hand-optimization, so one of the goals of R3 is to make 
the mezzanine functions powerful and efficient enough that they will 
actually get used rather than optimized away, and to make native 
the functions that need to be. The hope is that the users of REBOL 
can just use functions and trust that they will be efficient, rather 
than having to manually inline code all of the time.
Chris
15-Mar-2009
[12964]
Yey to that!
Graham
19-Mar-2009
[12965]
Is there a script around that decodes entities such as & etc 
?
btiffin
19-Mar-2009
[12966]
rebol.org   web-to-plain.r  handles a lot of them.
Oldes
19-Mar-2009
[12967x2]
http://box.lebeda.ws/~hmm/rebol/htmlentities_latest.r
(converts to utf8)
Graham
20-Mar-2009
[12969]
thanks.
Geomol
21-Mar-2009
[12970]
Is this logical behaviour? (Has it been discussed before?)

>> #"a" = 97
== true
>> switch #"a" [97 [print "found!"]]
== none
Chris
21-Mar-2009
[12971]
Inconsistent, perhaps.  Perhaps the first case shouldn't be, but 
can be extra useful (as can #'a" + 5)
PeterWood
21-Mar-2009
[12972x2]
I'm not sure about you're example but this would definitely seem 
to be a bug:

>> #"a" == 97
== true
The R3 behaviour is: 

>> #"a" == 97
== false


>> #"a" = 97

== true
Chris
21-Mar-2009
[12974]
I get:

>>  #"a" == 97
== false

in R2...
PeterWood
21-Mar-2009
[12975x3]
The implicit type convesion in evaluating #"a" = 97 is consistent 
with the help text :

>> ?
 =
USAGE
:
    value1 = value2
 

DESCRIPTION:

     Returns TRUE if the values are equal
. 
    = is an op value
.

ARGUMENTS:

     value1 -- (Type: any)

     value2 -- (Type: any)
I forgot that I was running 2.5.6 :-)
However I would ask why there is not an imiplicit type conversion 
in 

>> #"a" = "a" 
   
== false
Chris
21-Mar-2009
[12978x2]
Likely as char! is not a series type?
Seems a stretch as to-char "a" works, and to-char "ab" returns an 
error...
PeterWood
21-Mar-2009
[12980x2]
The implicit type conversion needed would be to change the char! 
to string! so as not just to compare the first element in the string!.


It would be a nice feature, but not essential. What would be helpful 
would be haivng the implicit type conversions doucmented.
It seems that there mat be a bug in R3:chat 

>> to char! "ab"

== #"a"
Geomol
22-Mar-2009
[12982x2]
Would it make sense to let this return true?
1
 = 1

There is a trap here, because we easily run in circles with char, 
string and integer. There are some special rules about char!, and 
it's probably hard to deside the best design.
In other words, would it make sense to compare apples and pears? 
We kinda do that with char and integer now.
PeterWood
22-Mar-2009
[12984x3]
I'm not sure that comparing char! and integer! is comparing apples 
and pears. Given that Rebol is written in C, it is most likley that 
internally it is stored as a char which is simply a single byte integer.
As for  "1" = 1 returning true, there is a case for implicit type 
conversions. Perhaps not a strong one, but the help text for = does 
imply that test is for equality regardless if type.

The implicit type conversion would need to be:

>> "1" = to String! 1

== true
The case for such implicit type conversion is somewhat strengthened 
by the existance of the == function.
Geomol
22-Mar-2009
[12987x4]
But you see the problem, if
#"a" = "a"
and
#"a" = 97
then
a
 = 97

which doesn't make much sense. But it could be a nice thing to have 
some of those implicit type conversions.
I agree, that the explanation for = isn't clear. Also because of 
special cases like:
>> "abc" = "ABC"
== true
Same can be said about ==:
>> "abc" == "ABC"
== false

It's the definition of the word "equal", that is a bit confusing.
Would it make sense to compare objects? Why not when blocks can be 
compared?

>> b: [1]
== [1]
>> b = [1]
== true
>> b == [1]
== true
>> b =? [1]
== false
>> o1: context [a: 1]
>> o2: context [a: 1]
>> o1 = o2
== false
>> o1 == o2
== false
>> o1 =? o2
== false
Gregg
22-Mar-2009
[12991x2]
http://www.rebol.net/wiki/Datatype_math_compatibility_tables


Those tables were generated programmatically, so I don't recommend 
editing the wiki manually. The idea is that running the generator 
will produce results based on acutal behavior. 


If we care about which version, that will need to be added, and we'll 
need a way to deal with the information. e.g., run under multiple 
versions and aggregate the results.
As much as it seems like adding coercions support would help, IME 
it only helps in *very* simple scenarios, and can lead to problems. 


As a historical note, when Visual Basic added the Variant data type, 
it started down this road and went so far that it eventually spawned 
a petition of "VBers against Evil Type Coercion".
Geomol
22-Mar-2009
[12993]
Interesting, Gregg. "In Python 3.0, coercion will not be supported." 
See:
http://docs.python.org/reference/datamodel.html#id5
PeterWood
22-Mar-2009
[12994x3]
Gregg: The table is great thanks. 


One small question, that started this thread, is char! compatible 
with integer! when:

>> same? #"1" 1

== false

>> same?
 #"1" 49

== true


The behaviour make sense based on an understading of character encoding 
but may appear incorrect at a higher level.
The entry in the Rebol dictionary for the = finciton  explains that 
it is case insensitive. == should be used for case sensitive equality 
checks.
The table suggests that, apart from a few exceptions, Rebol coerces 
numeric types and not non-numeric types. If this is the case, it 
would be good for this to be documented.
Geomol
23-Mar-2009
[12997x3]
I have sympathy for the opinion against coercion, if it is a real 
problem in real applications, but I also think, coercion can be good 
in many cases.


We have == (strict-equal?), and I think, it works as == (or =) found 
in many languages, and that is without coercion. And then we have 
=, that can be seen as a loose equal with coercion. I would like 
this coercion to be extended (if it makes sense), so these will give 
true:
1
 = 1
#"1" = 49
49
 = 49
a
 = "A"
a
 = 'a

1
 should not be equal to #"1", because this is true:
(first "1") = #"1"

(Just suggestions.)
The value tested against a string should simple have a to-string 
coercion, like an integer get a to-char if tested against a char.
("a" = "A" and #"1" = 49 in my example above is already true today.)
Gregg
23-Mar-2009
[13000]
Documentation is the most important aspect for me, so people know 
what to expect. 


I don't want = to be as loose as you do, John, but maybe a loose/load-equal? 
op could be added. It's not something I've ever felt I needed. What 
scenario(s) do you want it for?
Geomol
23-Mar-2009
[13001x5]
User type something in, and you wanna check, what number was input. 
Like:

if input = 42 [print "The answer!"]
I bet, we have a lot of TO-STRING or FORM around, that could be avoided, 
if = allowed coercion with strings, like it does with chars.
Maybe we could ask, where do you use = today, where you couldn't 
go with ==
And why?
What I'm after are very good arguments to have both equal? and strick-equal?. 
The less differences between them, the better argument to not have 
both. I think, both should be there, and equal? should have even 
more coercion than today. Maybe it even makes sense to take it further 
to include blocks? Should two series with the numbers 1, 2 and 3 
in them be equal?

123
 = [1 2 3]


Why not? Today we have to put to-string in front of the block to 
make them equal.
REBOL is about being human readable. Would a non-programmer find 
those two to be equal?