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

World: r3wp

[!REBOL3]

BrianH
19-Apr-2011
[8090x2]
If you want to make logical versions of AND, OR and XOR separate 
from their bitwise versions, that doesn't make any sense - their 
types already distinguish them. If you want to change AND, OR and 
XOR to be contitional, then the additional ops can behave like the 
current ops behavior: bitwise or logical, depending on argument types.
contitional -> conditional
Ladislav
19-Apr-2011
[8092]
OK, reading the Brian's formulations, a different expression of the 
poll question might be: "Do you, REBOL users, want to have 'combined' 
logic and bitwise' binary operators, wouldn't you prefer the operators 
to be conditional?"
onetom
19-Apr-2011
[8093]
(NOT could also be bitwise; if u ask a hardware guy...)
Ladislav
19-Apr-2011
[8094]
Sure, but that is not the question here, the question should be what 
do you prefer.
BrianH
19-Apr-2011
[8095]
If they are conditional (it would have to be including NOT), then 
the additional bitwise operators would be able to treat logic! values 
as if they were one bit.
Maxim
19-Apr-2011
[8096]
onetom, we already have the bitwise not... its called complement 
 :-)
BrianH
19-Apr-2011
[8097x2]
I would use the weird characters for the bitwise ops and the words 
for the logical ops. Maybe we could have ! be the same as COMPLEMENT 
instead of NOT.
words for the conditional ops, I mean
Ladislav
19-Apr-2011
[8099]
understood
Maxim
19-Apr-2011
[8100]
brian, logic values IMHO should be "all on" or "all off", which is 
what I'd prefer, its also more complementary,  as in 

not value or this-one

what'd you think?
BrianH
19-Apr-2011
[8101]
I mean, NOT would be the conditional not, and COMPLEMENT is the bitwise/logical 
not, same as now.
Gregg
19-Apr-2011
[8102]
What if we write a C dialect in REBOL, and confine all support for 
[! | & || &&  >> <<] ops to that? ;-)
BrianH
19-Apr-2011
[8103]
Logic and conditional values are all-or-not. Only bitwise is partial. 
For the one-bit logic! values, there's no difference.
PeterWood
20-Apr-2011
[8104]
I would probably vote for Ladislav's proposal if I knew which words 
were to be used for logical AND,OR etc. and which wold be used for 
bitwise.


For me, there is a clear advantage of additional clarity gained with 
separate  functions. I am not clear on the disadvantages (if any) 
of keeping them as single functions.
onetom
20-Apr-2011
[8105]
less words to learn and search in the dictionary.

the whole type system tries to build on this principle, so words 
can behave according to their context, just like in natural languages.
Ladislav
20-Apr-2011
[8106x2]
Peter, you may not have noticed, but I proposed all of the NOT, AND, 
and OR operators to be conditional. Their non-conditional counterparts 
already exist, and can be used for all the other purposes: COMPLEMENT 
(already not needing any change at all), INTERSECT (would need to 
add datatypes like LOGIC!, INTEGER!, CHAR!, TUPLE!, ...) and UNION 
(would need to add the datatypes like INTERSECT)
So, no new operators.
Maxim
20-Apr-2011
[8108]
and in fact XOR is the infamous ALTER.
Ladislav
20-Apr-2011
[8109x2]
Sorry Max, not at all.
ALTER is a modifying function.
Maxim
20-Apr-2011
[8111x3]
yeah... tought about it and I was going to say... forget it.
modifying or not, its not doing the same thing anyways.
so I guess we only have to find an new function name for XOR's bitwise 
variant?
Ladislav
20-Apr-2011
[8114x3]
DIFFERENCE
ah, sorry, it would need to be the COMPLEMENT DIFFERENCE
or not, I confused it.
Maxim
20-Apr-2011
[8117x3]
no it seems to work perfectly.  I just tried it.
(on blocks at least)
>> a: [1 2 3 4] b: [1 2 3 5]
== [1 2 3 5]
>> difference a b
== [4 5]

is exacty what I would expect of XOR on blocks.
Ladislav
20-Apr-2011
[8120x2]
>> difference make typeset! [none! unset! integer!] make typeset! 
[decimal! inte
ger! tuple!]
== make typeset! [unset! none! decimal! tuple!]


>> xor~ make typeset! [none! unset! integer!] make typeset! [decimal! 
integer! t
uple!]
== make typeset! [unset! none! decimal! tuple!]
So, yes, it should be DIFFERENCE
Kaj
20-Apr-2011
[8122x2]
less words to learn and search in the dictionary.
the whole type 
system tries to build on this principle, so words can behave according 
to their context, just like in natural languages.
Agreed, this is key
PeterWood
20-Apr-2011
[8124]
I feel a little confused. Are you proposing that DIFFERENCE be used 
for bitwise XOR?

So logically:

>> (#"^(40)" xor #"^(C0)") = (difference #"^(40)" #"^(C0)")
Maxim
20-Apr-2011
[8125]
I like the type adaptivity of REBOL and I build on it in all of my 
code, but in this case....


we have two completely different operations which can use the same 
datatypes in different ways... so there is no way to consolidate 
them.  hence this whole discussion
Ladislav
20-Apr-2011
[8126x2]
Are you proposing that DIFFERENCE be used for bitwise XOR?
 - I already wrote the ticket for it: http://issue.cc/r3/1879
But, unless you understand the difference between the conditional 
(NOT) and nonconditional (COMPLEMENT) operators, it is hard for you 
to find out what is going on.
onetom
20-Apr-2011
[8128x4]
the whole bitwise thing is pretty fucked up anyway. i tried to do 
a disk editor, a pic microcontroller HEX file processor, a custom 
serial communication protocol and in all cases i had to ping-pong 
between binary! issue! integer! and had to trim to the right bit/byte 
counts. it was a nightmare all the time.
it's big grief for me because rebol could be the bridge for hardware 
guys to the modern, internet connected world
no processing.org and arduino "C" crap..
now u want to apply set theory operation names to bitwise logic?
Ladislav
20-Apr-2011
[8132]
Yes, Tamas, it might be a good idea to suggest some improvements, 
if you are inclined to. You just need to realize, that there already 
are differences between the behaviour of R2 and R3.
Kaj
20-Apr-2011
[8133]
:-)
onetom
20-Apr-2011
[8134]
it sounds very impractical to me...
Ladislav
20-Apr-2011
[8135x2]
sounds very impractical

 - well, my suggestion was based on the fact, that the UNION already 
 works as OR in many cases anyway.
As an example, see the comparison of XOR and DIFFERENCE above.
onetom
20-Apr-2011
[8137]
Ladislav: im back to the Rebol world since my new job allows me to 
use it. if i can secure my position in the next few month, i definitely 
will make exact suggestions
Ladislav
20-Apr-2011
[8138]
Of course, an alternative to use a completely different set of names 
can be considered as well.
PeterWood
20-Apr-2011
[8139]
Actually, I use bitiwse  XOR and OR to perform arithmetic on characters 
in my string encoding utilities script.