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

World: r3wp

[Core] Discuss core issues

Ladislav
13-Oct-2006
[5575]
the example Mike liked is:

    view layout build/with [
        box 600x600 effect [
            draw [
                spider [
                    size 600x600
                    ; offset 100x100
                    pen black
                    scale 4
                    ; scale [0 150 300 450 600]
                    categories [

                        "Category 1" "Category 2" "Category 3" "Category 4"

                        "Category 5" "Category 6" "Category 7" "Category 8"
                    ]
                    directions
                    pen red
                    data [100 200 300 400 500 600 700 800]
                    pen blue
                    data [100 100 100 100 100 100 100 100]
                ]
            ]
        ]
    ] [spider: :spider*]

(it builds a DRAW block creating a Spider graph)
Henrik
13-Oct-2006
[5576]
** Script Error: spider* has no value
** Where: build
** Near: spider: :spider*
Ladislav
13-Oct-2006
[5577]
Spider is: http://www.fm.tul.cz/~ladislav/rebol/spider.r
Henrik
13-Oct-2006
[5578]
>> do http://www.fm.tul.cz/~ladislav/rebol/spider.r
connecting to: www.fm.tul.cz
Script: "Spider" (8-Sep-2006/16:40:58+2:00)
** Script Error: lfunc has no value
** Near: spider*: lfunc [
    [catch] 

    description [block!] "a block containing a description of a chart"
] [] [
    current-...
>>
Ladislav
13-Oct-2006
[5579]
use INCLUDE as follows:

do http://www.fm.tul.cz/~ladislav/rebol/include.r
append include-path http://www.fm.tul.cz/~ladislav/rebol/
include %spider.r
Henrik
13-Oct-2006
[5580]
it wants to find the file in my local cache before the remote one 
and crashes:

>> do http://www.fm.tul.cz/~ladislav/rebol/include.r
connecting to: www.fm.tul.cz
Script: "Include" (5-Jan-2006/14:31:42+1:00)
>> append include-path http://www.fm.tul.cz/~ladislav/rebol/
== [%. %/Volumes/c/rebol/ http://www.fm.tul.cz/~ladislav/rebol/]
>> include %spider.r
connecting to: www.fm.tul.cz
** Access Error: Cannot open /Volumes/c/rebol/spider.r
** Where: include-script
** Near: found: load/all target 
if header
>>

Sorry, if I'm being a little difficult :-)
Ladislav
13-Oct-2006
[5581]
no problem, checking what went wrong in your case
Henrik
13-Oct-2006
[5582]
>> what-dir
== %/Volumes/c/rebol/

if that helps.
Ladislav
13-Oct-2006
[5583x4]
OK, give me a few minutes to check the versions
aha, this looks like a result of the last INCLUDE change. It is surprising, 
that nobody noticed it yet.
Henrik: could you please test again?
(INCLUDE bug corrected)
Henrik
13-Oct-2006
[5587x3]
same error
I can see that the script dates for include.r are different, so it 
must be the new version
ah... a fresh console helped.
Ladislav
13-Oct-2006
[5590]
yes, INCLUDE does not reload itself when already defined
Henrik
13-Oct-2006
[5591]
back to the example: what exactly does Spider do? I don't think it's 
very clear from the example what's going on. there could be hundreds 
of lines of code hidden there.
Ladislav
13-Oct-2006
[5592x2]
you need to have a look at http://www.fm.tul.cz/~ladislav/rebol/spider.r
. It generates the spider graph as you could see, if you succeeded 
to run the code
Henrik: could you please do one more test - I updated INCLUDE once 
again
Henrik
13-Oct-2006
[5594x2]
I saw it. The draw block would then be evaluated from the spider 
code and then inserted at that place?
include still works fine in a fresh console
Ladislav
13-Oct-2006
[5596]
yes, you can see the result of it if you do:

probe build/with [
        box 600x600 effect [
            draw [
                spider [
                    size 600x600
                    ; offset 100x100
                    pen black
                    scale 4
                    ; scale [0 150 300 450 600]
                    categories [

                        "Category 1" "Category 2" "Category 3" "Category 4"

                        "Category 5" "Category 6" "Category 7" "Category 8"
                    ]
                    directions
                    pen red
                    data [100 200 300 400 500 600 700 800]
                    pen blue
                    data [100 100 100 100 100 100 100 100]
                ]
            ]
        ]
    ] [spider: :spider*]
Henrik
13-Oct-2006
[5597]
I guess I'm just really hard to impress today. I need a much sexier 
example to be convinced of the raw power of BUILD. :-)
Ladislav
13-Oct-2006
[5598]
:-)
Henrik
13-Oct-2006
[5599]
something like "this takes 100 lines of code to do with regular REBOL 
block construction functions, while BUILD can do it in 20 and make 
much prettier code out of it"
Ladislav
13-Oct-2006
[5600x2]
I have got a similar XYPLOT function creating an XY graph, although 
I did not release it yet
Well, how would you do the

view layout build/with [
        box 600x600 effect [
            draw [
                spider [
                    size 600x600
                    ; offset 100x100
                    pen black
                    scale 4
                    ; scale [0 150 300 450 600]
                    categories [

                        "Category 1" "Category 2" "Category 3" "Category 4"

                        "Category 5" "Category 6" "Category 7" "Category 8"
                    ]
                    directions
                    pen red
                    data [100 200 300 400 500 600 700 800]
                    pen blue
                    data [100 100 100 100 100 100 100 100]
                ]
            ]
        ]
    ] [spider: :spider*]

example without using BUILD?
Pekr
13-Oct-2006
[5602]
Ladislav - will build be part of R3? :-)
Ladislav
13-Oct-2006
[5603]
That is why I am asking here - if there are users who will be using 
it
Henrik
13-Oct-2006
[5604]
by looking at it, SPIDER looks like a regular function to me with 
the following block as input. I guess it can't be, because then the 
layout block could simply be done by enclosing spider [...] in ()'s 
and compose/deep the whole thing.
Ladislav
13-Oct-2006
[5605]
compose/deep - actually it could be used in this case, because I 
didn't use parens anywhere
Henrik
13-Oct-2006
[5606]
well, just getting rid of ()'s isn't enough for me. I would want 
significant code reduction in cases where blocks would be cumbersome 
to build.
Ladislav
13-Oct-2006
[5607x2]
this is not about getting rid of parens, this is about *not clashing 
with parens*
With COMPOSE/DEEP you cannot use parens safely
Henrik
13-Oct-2006
[5609]
by safely you mean selective evaluation?
Ladislav
13-Oct-2006
[5610x2]
yes
imagine I need parens in the layout block. Then I am getting out 
of luck with compose/deep
Henrik
13-Oct-2006
[5612]
I can see that now. I've just not run into a case like that, I guess. 
:-)
Ladislav
13-Oct-2006
[5613]
it is not that rare to use parens in the layout block, I guess
Henrik
13-Oct-2006
[5614]
that would be cases where you need to compose things during runtime 
and not "layout time"
Ladislav
13-Oct-2006
[5615]
another example: if you look at the SPIDER implementation, you will 
see it is implemented using BUILD too. I bet it would be much harder 
with compose, because there *are* parens in the implementation.
Henrik
13-Oct-2006
[5616]
are you going to prepare docs for it?
Ladislav
13-Oct-2006
[5617]
I am not sure I know what to write ;-), maybe I should ask somebody 
else
Henrik
13-Oct-2006
[5618]
well, if some good examples came into place, then I think it would 
be possible to write a little bit around it.
BrianH
13-Oct-2006
[5619]
Well, you know I'm in favor of including BUILD in the default REBOL. 
You clash with parens all the time when building parse rules.
Ladislav
13-Oct-2006
[5620x2]
Brian: right, for parse rules it is much better than compose
Actually, we might use something like REDUCE/DEEP/ONLY, if the /DEEP 
refinement existed and if /ONLY specified the words that should be 
evaluated instead of the unevaluated ones
Pekr
13-Oct-2006
[5622x2]
hmm, what if you have more parens, containing the same words, and 
one you want to evaluate, while second you don't?
just theoretising, not knowing what actually 'build is about ....
Ladislav
13-Oct-2006
[5624]
good question, Pekr. Answer: you can choose any new word you want 
to for the evaluation - especially some words you know you cannot 
encounter in the block are good.