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

World: r3wp

[Core] Discuss core issues

Pekr
31-Jul-2007
[8596]
really? What is that refinement there for then? :-) Well, it might 
be understandable - read in opposite to open just can't be so fine-grained 
...
Henrik
31-Jul-2007
[8597]
it probably depends on the webserver, if it will deliver only part 
of the page or not.
Pekr
31-Jul-2007
[8598]
IIRC I tested open/part and skip and it worked, but it was long time 
ago ...
Gabriele
31-Jul-2007
[8599]
R2's HTTP does not support that kind of things.
Geomol
1-Aug-2007
[8600]
I'm so irritating happy today! :-D (You may not be able to say such 
in english, but it works in danish.)
Henrik
1-Aug-2007
[8601]
it does? :-D
Geomol
1-Aug-2007
[8602x2]
Ops, wrong channel, that should have been in the "Chat" group.
Oh my, I'm just irritating! :-)
Pekr
4-Aug-2007
[8604]
Today I was thinking about REBOL paths and namespaces navigation 
"problem". I would like some clever persons 

here, to educate me a bit in that area. So far I think, that REBOL 
breaks on some path rules, of course it 

depends, upon what "philosophy" you provide as an explanation. So, 
I was thinking about 

namespaces/paths/context, as of a tree .... So, all words are defined 
in top (global) context = root, right? 

(excuse simplification). Then comes first question - how can be following 
valid?:

a: 5
b: context [print a]


My objection is, that from the point of  'b "node", there is no 'a. 
So, my explanation is:

1) in the case of directory, we would use ../a
2) or we should go via root reference - b: context [print /a]

3) we create "philosophical" rule, stating that global (top) context 
words are propagated to subsidiary nodes 
(contexts)


I don't mind case 3), if such rules are well defined, and it will 
come, once we switch to modules.


How did I came to think about above? I have somehow aesthetical issue 
with REBOL, when I look at e.g. scheme 

code in R2. It is full of awfull system/words/word references. I 
don't like it. What I would like to see is to 
have some abbreviations. I know that we can do e.g.:

_print: system/words/print


My question is, if we could have some more abstracted solution? Do 
you remember 'with keyword? I don't 

remember how it worked, but I would like to have some ability to 
"bind" particular word from existing context 
to actual context:

bind system/words node here, so that I don't need to use paths
 (kind of like when you create links in unix 
filesystem hierarchy ....


Of course, here we go - we could easily get some colision, e.g. if 
target context contains the same words. But 

maybe that could be somehow taken care for (I thought e.g. about 
automatic adding of underscores, e.g. _print, 
but that is not good solution).


Well, the thing is, that I am not actually even sure, what am I asking 
for :-) So, I would like to ask, if 

some REBOL gurus thought about such topics, or am I completly unrealistic 
here?

Thanks ...
Geomol
4-Aug-2007
[8605]
Some thoughts:

Case 3) is like in object-orientated languages. You inherit words 
from parent context (object or class) and can use them right away 
without any further syntax.

You'll probably see system/words/word references in cases, where 
it is words that very like get reused/redefined. So it's typed like 
that to make sure, it's the system definition of the word, that is 
being used.

I'll give you, it's not the most pretty and easy to read. Maybe some 
use of BIND can avoid it.
btiffin
4-Aug-2007
[8606]
Pekr;  I'm kinda of kidding, but not.  Avoid Multiple Inheritance 
 it a plague :)
Gabriele
4-Aug-2007
[8607]
Petr, there is no such hierarchy in REBOL. there is no "parent" or 
"child" context.
Pekr
4-Aug-2007
[8608x2]
and maybe that is wrong?
I remember QNX, everything in system was hierarchical, accessible 
via nodes. As you think of compositing engines, networking, filesystems, 
- all use hierarchies/trees. I just thought that because REBOL got 
paths, we could put more thoughts to it and make it an universal 
aproach :-)
Gabriele
4-Aug-2007
[8610x2]
that is not wrong.
and, changing that would mean making something that is not rebol 
anymore.
btiffin
4-Aug-2007
[8612]
I agree.  Relative context is the way to go.  (But, always a but), 
Petr's point about system/words/copy inside the scheme overlays seems 
a little, hacky? for such core functionality.  I'd almost prefer 
to see the scheme front end code made a little more complex and include 
a uses block or some such that allows clear mapping from redefined 
words to 'previous' behaviour.
Gabriele
5-Aug-2007
[8613x2]
who makes you think that the system/words/copy thing happens in R3 
schemes?
who = what
Geomol
5-Aug-2007
[8615]
:-) Nice!
btiffin
5-Aug-2007
[8616]
I was hoping..., but didn't want to say anything.  :)
Joe
14-Aug-2007
[8617x2]
hi, how do I go about timing out ports opened with direct/no-wait
thanks
Pekr
14-Aug-2007
[8619x2]
what do you mean by timing out?
when you use direct/no-wait, it does not wait. You have to explicitly 
call wait to get events. Also copying from port does not block ...
sqlab
14-Aug-2007
[8621x2]
Hi Joe
something like 
either port: wait reduce [opened-port1 opened-port2 timeout] [
	print "data available"
	probe copy port
] [
	print "timeout"
]
You can also have a look at dispatch
james_nak
15-Aug-2007
[8623]
I was wondering if I am going about searching for particular values 
wrong. If I have a block of objects  and I want to search for a particular 
value within one of those objects should I go though each obj using 
something like "foreach" or is there a better way.
For example
movies: [m1 m2 m2]
where m1 is an object with a "title" value, etc.

foreach movie movies [
  if movie/title == "Star Wars" [.....]
]
Of course that works but it seems primitive.
Brock
15-Aug-2007
[8624x2]
I'd be interested in seeing what others do in this situation as well. 
 I believe most people would be using one of the sql options available 
to clean this up.
I know there is a sql dialect out there, it would be interesting 
to know how it performs this type of query.
Gregg
15-Aug-2007
[8626]
Don't confuse "primitive" with "simple and obvious".  :-)  Without 
trying to avoid answering your question (what you're doing is fine 
:-), let me ask some questions in return:


What is your goal? Do you want to improve readability? Allow users 
to enter queries? Improve performance? What goes in the [....] block? 
What would you have to do to perform this task *without* examining 
each object?
james_nak
15-Aug-2007
[8627]
Gregg, well in the back of my mind since I started programming with 
BASIC, C and Assembler (which, without wanting to start an Altme-war, 
I refer to as 'procedural' as opposed to OO), I was just wondering 
if there was another "object-oriented" way. You know, like "find" 
but with special parameters that tell it to do what my "foreach" 
actually does. I don't know, it just seemed kind of "Dorky." : )

I'm writing an app that will produce php code to help me administer 
mysql db's. I'm at the point where it can read the table and field 
data and create objects with that info. Now I'm at the part where 
it goes back and pulls that data out. So, I've assigned each table 
an index # then in the "columns" object, it refers back to that index. 
Since I have a block of those column objects I was just looking for 
a spiffy way of finding which ones, for example, of finding all of 
the objects that are part of table index #3.

I've always used the "foreach " method but you know, I'm always looking 
for a way to improve my code. Thanks Gregg for your input.
Geomol
15-Aug-2007
[8628]
James, are you after a search three? Do you know those data structures? 
Examples are binary search threes, B-threes, etc.
BrianH
15-Aug-2007
[8629]
Do you mean tree?
Geomol
15-Aug-2007
[8630]
Yes, of course! Tree! Sorry about that.
james_nak
15-Aug-2007
[8631]
Actually I was just wanting to know if I was missing something in 
the way I am checking for a value within an object that is part of 
a block of objects. Nothing really sophisticated and these blocks 
are really small so no need for speed increases. 

To be frank,  I often look at the code you all write and say to myself: 
" Self, how in the world did they think of that?" or "Oh, I didn't 
know you could do that." For example when I first started using Rebol, 
I didn't know about the  "in" word as in "Get in object 'word.." 
so I was always using paths and trying to figure out how one would 
make the path a "variable." (object/mypath, where mypath could be 
some changing value). 
Thanks for your input though.
Geomol
15-Aug-2007
[8632x2]
Maybe you could make a block with the titles and the objects together, 
and then just use a path to get to the object? Something like:


>> movies: reduce ["Star Wars" make object! [status: 'good!] "Matrix" 
make object! [status: 'cool]]
>> movies/("Star Wars")/status
== good!
>> movies/("Matrix")/status
== cool
I'm just throwing ideas! :-) Work with it.
james_nak
15-Aug-2007
[8634x2]
You see, stuff like that is very interesting to me.
I didn't know you could use ( ) like that.
Geomol
15-Aug-2007
[8636]
I think, we were allowed to use () in paths in recent versions of 
REBOL. Not exactly sure when.
james_nak
15-Aug-2007
[8637]
Why doesn't anyone tell me these things? : )
Rebolek
15-Aug-2007
[8638x2]
james_nak: http://www.rebol.com/article/0025.html:)
it's almost three years...time runs so fast :)))
Gregg
16-Aug-2007
[8640]
Another thing to consider is that this is a general need, so FOREACH 
(e.g.) may be used, but you can hide it in a wrapper func, maybe 
called SELECT-ALL, that works like REMOVE-EACH. I have different 
variations, based on how other langs do it, e.g. select/inject in 
smalltalk. Here's a very quick way to leverage REVMOE-EACH.

    filter: keep-each: func [

        "Keeps only values from a series where body block returns TRUE."

        'word  [get-word! word! block!] "Word or block of words to set each 
        time (will be local)"
        series [series!] "Series to traverse"

        body   [block!]  "Block to evaluate. Return TRUE to collect."
    ] [
        remove-each :word series join [not] to paren! body
    ]
    comment {
        filter x [1 2 3] [x = 2]
        filter x [1 2 3] [odd? x]
        filter res [1 2 3] [odd? res]
        filter [x y] [a 1 b 2 c 3] [all [odd? y  'c = x]]
    }
james_nak
16-Aug-2007
[8641]
Thanks Gregg and Rebolek!
Joe
17-Aug-2007
[8642]
pekr,sqlab, thank you for your answers. I thought that sync ports 
also had a timeout like the async kernel (set-modes port [timeout: 
30]) but they do not. thanks
Henrik
20-Aug-2007
[8643x2]
I may be the last to learn this, but I didn't know you could do this:

>> type? first [none]
== word!
>> type? first [#[none]]
== none!
which is neat :-)
Geomol
21-Aug-2007
[8645]
Any thoughts on this?

>> #"a" * 2
== #"Â"
>> 2 * #"a"
== 194


So multiply is commutative in a 'funny' way. In this example, you 
get the result in the same datatype as the first argument. This also 
works:

>> #"a" * 2.0
== #"Â"

But you can't do:

>> 2.0 * #"a"
** Script Error: Cannot use multiply on decimal! value


So multiply is not commutative, when it comes to decimals and chars. 
Any comments? Also think of other datatypes, you wanna multiply.