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

World: r3wp

[!REBOL3]

onetom
20-Apr-2011
[8130x2]
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.
Maxim
20-Apr-2011
[8140]
although having the set functions support the bitwise ops like they 
should...

I *also*I want bitwise infix ops... as long as the set functions 
to do the same arithmetic... basically just like how  'ADD  and  
'+  are equivalent.
Kaj
20-Apr-2011
[8141]
If the broader problem would turn out to be unsolvable in the REBOL 
dialect, there will still be an R3 extension with a Red/System dialect
PeterWood
20-Apr-2011
[8142]
So, if I understand correctly, I would write someting like:

iso-ch: union #"^(40) utf-ch-2

and 

utf-ch: rejoin [#"^{C3}" difference #"^(40)" iso-ch]
Ladislav
20-Apr-2011
[8143]
- that is one possibility
PeterWood
20-Apr-2011
[8144x3]
It does look a little unusual but probably the equivalents with OR 
and XOR look odd to other people.
It's a long time since I studied set theory but if I remember correctly, 
the union of two sets is not dependant upon the order of the elements 
in a set.


So shouldn't the UNION of two sets of bits really be one of three 
values {0}. {1} or {0,1}.


I know this is knitpicking but I'm very used to XOR being bitwise.
Union appears to be implemented so in R3:

>> union [ 0 0 0 0 1 0 0 0] [ 0 0 0 1 0 0 0 0 ]
== [0 1]
BrianH
20-Apr-2011
[8147x3]
Ladislav, http://issue.cc/r3/1879is a bit complicated when you consider 
that "operator" is used in REBOL jargon only for infix operations.
Your request looks like 3 related tickets:

- Extend the INTERSECT, UNION and DIFFERENCE functions to include 
the current bitwise behavior of AND, OR and XOR, respectively.
- Make operators for those functions (maybe &, | and ^).

- Change AND, OR and XOR operators (and AND~, OR~ and XOR~ functions) 
bitwise behavior to conditional behavior.
Is this a reasonable assessment of your request?
Peter, your right about the set functions and blocks. We should mention 
that in the ticket and say explicitly that these would not be set 
functions when applied to integers and such. The problem is that 
we would need bitwise operations to apply to strings and binaries 
as well, and these functions already treat them like sets. So there's 
a bit of functionality overlap that we have to deal with or else 
something will be lost.
your -> you're
Gregg
20-Apr-2011
[8150]
The goal of having less dictionary entries to remember, and having 
the ops be smart, is valid; but in this case I think the meaning 
of the set op funcs (e.g. difference, union, etc.) are *much* clearer. 
Yes, most of us see AND and OR and know what's going on (though it 
sometimes makes my brain stutter a bit when debugging, especially 
XOR :-).
BrianH
20-Apr-2011
[8151x6]
Having the set operations not act like set operations for some datatypes 
is only a little confusing - not much worse than what we have now. 
Losing either the setwise or the bitwise operations for strings and 
binaries is a much bigger problem - we need both, in different circumstances.
Sorry, just binaries. Good, I was worried that they might have tried 
to implement bitwise operations on R3 strings, which (conceptually) 
don't have a bitwise definition.
Though bitwise operations are allowed on chars, so that's a little 
inconsistent.
I think that not allowing bitwise operations on strings is a pragmatic 
restriction, because the internal data might get corrupted by them, 
and at the very least the results would be different depending on 
which internal storage mode is used. I'm not sure whether bitwise 
operations on characters currently work correctly at all, for the 
same reasons. What would be the proper behavior, and how can we check?
OK, just checked, characters are operated on as if they are integers 
of the same numeric values; that will do. We can't implement this 
in string form because we don't support UCS4 internally.
Note: COMPLEMENT doesn't support char!, probably because it would 
always result in characters that string! doesn't support, or even 
Unicode in many cases. This would continue to be the case with this 
proposal.
Ladislav
20-Apr-2011
[8157x2]
Make operators for those functions (maybe &, | and ^).

 - that is not what I am suggesting. Somebody else could, but I do 
 not need infix operators for that.
Losing either the setwise or the bitwise operations for strings and 
binaries is a much bigger problem

 - I do not understand, how you can lose something you do not have?
BrianH
20-Apr-2011
[8159x3]
OK, that is why I was suggesting a separate ticket. Do you mind a 
little rewording in the ticket, or splitting into more tickets, if 
the proposal stayes the same, semantically? This would allow us to 
make them more precise, and show competing proposals, some of which 
could be rejected in favor of others. The existing ticket seems like 
a summary of an AltME conversation, so it would be tricky for an 
implementor to follow.
We have bitwise operarions on binaries. They could be considered 
to be more important than the bitwise operations on integers in some 
cases.
We also have setwise operations on binaries. They are probably less 
important, but I'm sure some people would miss them.
Ladislav
20-Apr-2011
[8162x4]
My main concern is to make the text readable for the uninitiated. 
The text, if split into more tickets, loses meaning, and I would 
not understand why such proposals are there.
Of course, I can imagine that some alternative proposals to this 
may be as good or better than this one.
My main concern really is the fact, that REBOL is the only programming 
language I know not having conditional AND and OR.
(for the "strict" languages, which allow only logic! values to be 
conditional, the logic operators *are* conditional, for the non-strict 
languages, there is no problem either, since their AND and OR are 
conditional, only REBOL has chosen to not have conditional AND and 
OR)
BrianH
20-Apr-2011
[8166]
Well, the setwise-vs-bitwise treatment of binaries is a real issue 
with the INTERSECT, UNION and DIFFERENCE functions, so one alternate 
proposal would be to use different function names for the bitwise 
functions/operators. This would allow one or the other proposal to 
be rejected. Also, the operators proposal would need to be seperate, 
so it could be separately rejected. We've done this with other competing 
proposals before, so it's established practice. Why don't I come 
up with a set of proposals and run them by you first?
Ladislav
20-Apr-2011
[8167x2]
Setwise treatment of binaries is a no-issue for me. I wonder, whether 
it really is an issue for somebody else.
But, as I said, my main concern is the "REBOL does not have conditional 
AND and OR", so, if you succeed to split it up in a way this still 
is obvious, I will be OK with it.
BrianH
20-Apr-2011
[8169]
If it's not, then the INTERSECT, UNION and DIFFERENCE proposal could 
be accepted and the BIT-AND, BIT-OR and BIT-XOR proposal (or whatever 
you prefer as an alternate convention) could be rejected. Rejection 
of a proposal is not a problem in this case - rejection of *both* 
proposals is a problem.
Ladislav
20-Apr-2011
[8170]
Yes, I suggested the INTERSECT, etc. modification as a supporting 
matter to show how one can do without changing too much. I can imagine 
a lot of different alternatives, though.
onetom
20-Apr-2011
[8171]
in what context usually is it an issue not having "conditional" logic 
operators?
can u give some actual examples?
BrianH
20-Apr-2011
[8172]
if condition and find data something [...]
onetom
20-Apr-2011
[8173]
for which case was the 'found? function been invented
Ladislav
20-Apr-2011
[8174]
I see it is the main purpose why the AND and OR operators are needed 
at all. We don't need them that much to yield logic values as we 
need them to yield condition values. My main argument is the comparison 
of NOT usage (which is conditional, and used a lot), versus the COMPLEMENT 
usage (which is nonconditional, compatible with AND and OR, yet used 
much less)
onetom
20-Apr-2011
[8175]
still have to convert the condition to-logic, i got that, but i got 
used to the any, because most of the cases we don't need to eval 
everything
Ladislav
20-Apr-2011
[8176x2]
Tamas, did you read the ticket? I do not want to repeat everything 
I wrote in there.
(would be impractical)
BrianH
20-Apr-2011
[8178]
Yup, onetom. But mixing prefix and infix is awkward in REBOL, requiring 
a lot of parentheses. This makes REBOL code slower and uglier.
onetom
20-Apr-2011
[8179]
Ladislav: sorry, i was just following the chat here. will read the 
ticket.