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

World: r3wp

[!REBOL3]

Maxim
21-Apr-2011
[8215x2]
it raises the question, well what are these ops... and the answer 
is that there are none.   its a strange hole in the language spec 
which has passed under the radar for a really long time.
its very possible that REBOLers think in a different way and using 
ANY/ALL is more natural, hence the unatention this has had.
Geomol
21-Apr-2011
[8217]
I don't agree, they're only used bitwise, as this example illustrate:

>> a: 1 b: 2
== 2
>> if (a = 1) and (b = 2) [print "it's true"]
it's true
Ladislav
21-Apr-2011
[8218x2]
Geomol: I don't understand, why you say
REBOL does not have conditional AND and OR


Excerpt form the above definition of "conditional operator": "...being 
able to combine conditional expressions into more complex conditional 
expressions..."


The demonstration that AND and OR are not able to combine conditional 
expressions into more complex conditional expressions is easy
(and has been done already)
Geomol
21-Apr-2011
[8220x2]
I just got confused by the wording. :-)
Is it correct to say, that AND and OR can be used as bitwise operators 
and to check on logic! values. And that e.g. IF can do more than 
this and then isn't really compatible with AND and OR?
Maxim
21-Apr-2011
[8222x3]
geomol, logic types are single precision states.  on or off.  any 
operation between logic values are implicitly bitwise.
yep.
you just got the differentiation between conditional and logical 
comparisons.
Geomol
21-Apr-2011
[8225x2]
Ah yes, you can say that about bitwise. Makes sense.
I'm just used to not think in bits when dealing with logics.
Ladislav
21-Apr-2011
[8227]
I am trying to use a slightly different formulation: IF can check 
not just logical expressions (yielding LOGIC! values), but conditional 
expressions (yielding any values). We do not have operators combining 
conditional expressions into more complex conditional expressions 
(ANY and ALL are dialects, not operators, although they can be used 
successfully).
Geomol
21-Apr-2011
[8228]
Sounds good to me.
Maxim
21-Apr-2011
[8229]
geomol,  I come from electronics background wrt logic... so I can't 
make the difference  ;-)   I studied logic as digital circuits vs. 
 analog circuits.
Geomol
21-Apr-2011
[8230]
Is an analog circuit only partly true or false? :-)
onetom
21-Apr-2011
[8231x2]
maybe truish while probably falsy :)
Ladislav: very clear and concise description. i would emphasize the 
operator by saying "..don't have any op!s combining.."
Maxim
21-Apr-2011
[8233]
to a digital circuit, an analog circuit is like quantum physics, 
it seems impossible, but it works .   ;-)
onetom
21-Apr-2011
[8234]
it's interesting to think about ANY/ALL as dialects...
Maxim
21-Apr-2011
[8235]
so... can we say that analog is the future of digital ?   ;-)
Geomol
21-Apr-2011
[8236x3]
I like analog more and more. Buying analog synths, trying to build 
analog circuits making sound.
onetom, I guess, you can see all functions taking a block as an argument 
to be dealing with dialects. The content of the block is just words 
until the function start to interpret it and give meaning to it.
Or maybe more correctly, the content of a block is datatypes (words, 
numbers, etc), and then the function start to make sense of it.
onetom
21-Apr-2011
[8239]
yeah, but in this case the default rebol evaluator is the 1st and 
almost only thing which touches that block, that's why i overlooked 
this
Geomol
21-Apr-2011
[8240]
The fact, that ANY and ALL are natives, is maybe just to make them 
faster. It should be possible to create them as functions. One project 
of mine is to figure out, what minimum set of natives is needed for 
a REBOL like language, and the rest can then be implemented as functions.
onetom
21-Apr-2011
[8241x3]
it would be a nice groundwork for implementing rebol-like languages 
over others
like the lisps in javascript
we are off-topic though
Geomol
21-Apr-2011
[8244]
What's the right group for this? Core maybe?
Maxim
21-Apr-2011
[8245x2]
Red?  ;-)
isn't this what Red/system is all about?
BrianH
21-Apr-2011
[8247x2]
It is definitely possible to implement ANY and ALL as functions if 
you use DO/next (either the R3 or R2 version).
You use the OP function to make op! values, and 'op gets unset after 
the mezzanines finish loading because of security/stability (I think 
OP doesn't have a lot of safety checks yet). TO-OP isn't defined. 
You can't currently make an op like Geomol's FROM because you can 
only currently make ops redirect to native! or action! functions 
- you can't make the necessary wrapper function. This is all afaik, 
based on conversations with Carl; I haven't tested this very much 
yet.
Maxim
21-Apr-2011
[8249x2]
to-op is defined, but it doesn't accept function! values.
it would be really nice to have this... we can make a lot of things 
look like natural language with this.
BrianH
21-Apr-2011
[8251]
Really? It's not defined at runtime. Maybe it gets unset after the 
mezzanines are done loading too.
Maxim
21-Apr-2011
[8252]
fire up R3 and type:

>> help to-op
USAGE:
        TO-OP value

DESCRIPTION:
        Converts to op! value.
        TO-OP is a function value.

ARGUMENTS:
        value
Geomol
21-Apr-2011
[8253]
Maybe you're using different builds?
BrianH
21-Apr-2011
[8254]
I did that. TO-OP was unset.
Maxim
21-Apr-2011
[8255]
ok,  it's probablly been removed then... I'm still using an ancient 
version for the chat.
BrianH
21-Apr-2011
[8256x2]
It is planned to support making ops from other kinds of functions, 
but it hasn't been done yet.
The current version supports chat just fine.
Maxim
21-Apr-2011
[8258x2]
there are a lot of things I'd setup as an OP.   the FROM example 
from geomol is a really good example of how this makes code sooo 
much more readable.
it also allows to alleviate some parens in expressions if the functions 
are ops instead.
BrianH
21-Apr-2011
[8260]
There are some real limits to op! evaluation that makes them unsafe 
for general use for now. For one thing, the type of the first argument 
is not checked at call time relative to the typespec by the evaluator 
- it has to be checked by the function itself internally. This is 
not a problem with most existing ops because they map to actions 
(which have their type compatibility handled by the action dispatcher), 
or in some cases natives that perform their own internal type checking. 
I believe this was a speeed tradeoff. If you allowed full user creation 
of ops even with their current restriction to actions and natives, 
you could bypass the typespecs of natives and corrupt R3's memory. 
Adding in that typespec check to the op! evaluator would slow down 
op! evaluation a little, but would be necessary if you really wanted 
to make user-defined ops possible.
Maxim
21-Apr-2011
[8261x3]
I don't mind since we need to build a stub anyways... its easy to 
add this checking there.
the to-op function could easily just raise an error if the first 
paramater has any type spec.   that' how I'd handle it.
this forces people to make the stub, so it becomes a programming 
error, not a language bug.
BrianH
21-Apr-2011
[8264]
That would fail for = and all other functions that allow the any-type! 
value (for unset! and error! support), and make it difficult to understand 
the help of all op functions, which use the typespec of the first 
argument for documentation purposes. Plus, the argument list for 
the op! is taken directly from the function it is derived from - 
it can't and shouldn't be able to be specified separately.