• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

AltME groups: search

Help · search scripts · search articles · search mailing list

results summary

worldhits
r4wp5907
r3wp58701
total:64608

results window for this page: [start: 23601 end: 23700]

world-name: r3wp

Group: Rebol School ... Rebol School [web-public]
Geomol:
8-Feb-2009
Henrik, is there an example of a user defined datatype in R3 somewhere?
Geomol:
8-Feb-2009
No, I try not to. It's nice to have kind of globals in a long script, 
to easily share values between functions, but then I put the whole 
thing within a context block, like:

context [

... all my code go here ...

]	; end of context
Geomol:
8-Feb-2009
CONTEXT is a function, and you can see, what it does with:

>> source context
kib2:
8-Feb-2009
Henrik: that' seems a good way to handle namespaces ?
Henrik:
8-Feb-2009
context [
  a: 1 ; only inside context
  set 'b 2 ; global
]


This can be useful, if you want to create an object with one "public" 
function.
Henrik:
8-Feb-2009
kib2, since you can bind contexts everywhere, even inside other contexts, 
they are not really secure and so you can't make things really private 
to a context. Modules will do that, I believe.
Janko:
8-Feb-2009
+ in this two cases "dispatches" on the type of arg... but this is 
probably handlede inside + , so if you define new type (vector3d) 
you couldn't make + work for that datatype too without changing it 
... in multiple dispatch + is a generic word and you add definitions 
for it for that datatype so it can work on them without changing 
or having access the original +  (basically similar to what is operator 
overloading at static lang, here it dispatches in runtime based on 
type)
Geomol:
8-Feb-2009
Janko, I've been thinking about this problem too, and I'm not sure, 
what's best. Is it good enough, what we can do with functions today? 
Like:

>> old-add: :add

>> add: func [a b] [either string! = type? a [join a b] [old-add 
a b]]
>> add 4 5
== 9
>> add "Hi " "John"
== "Hi John"

Now ADD can also be used to join strings.
Janko:
8-Feb-2009
make-type dog!
make-type cat!

make-generic 'say

say: func [ a [ dog! ]] [ "woof" ]
say: func [ a [ cat! ]] [ "meov" ]
Janko:
8-Feb-2009
make-type dog!
make-type cat!

make-generic 'say [ a [ dog! ]] [ "woof" ]
make-generic 'say [ a [ cat! ]] [ "meov" ]
Geomol:
8-Feb-2009
kib, to avoid confusion, remember that everything in REBOL is a word. 
The word in itself doesn't have a certain meaning. The words have 
meaning, when used in a context. The same word can mean different 
things in different contexts. And you can redefine everything, even 
things like: + and -
Geomol:
8-Feb-2009
I guess, a number like 1 can't be said to be a word, and it can't 
be redefined. But you can make a dialect, in which 1 means something 
else. So you have words, numbers, blocks, etc. The words can be redefined 
to suit your needs.
kib2:
8-Feb-2009
so is there something like quotations in Lisp ? ie something to get 
a word not to be evaluated
Geomol:
8-Feb-2009
>> a: 2
== 2
>> b: a
== 2
>> c: 'a
== a
kib2:
8-Feb-2009
Steeve: In fact I've leaved because Carl was not in the mood for 
releasing a public R3 (see my posts on his blog). Then he was kind 
enough to change his mind...
Janko:
8-Feb-2009
also blocks don't evalueate , thats thy you can make your own >>do-five-times 
[ print "ups" ]<< which is a stupid example :)
Janko:
8-Feb-2009
but quotations in factor are still more special case, you have curry 
and few words for them , but in rebol code block is the same as ordinary 
data block ( like a sequence { asdasd asd asasd } in factor so you 
can use insert append remove next ... etc on it .. I imagine factor 
is more limited here because it compiles things, here you can process 
your block of code just the same as data and then run it
kib2:
8-Feb-2009
I've downloaded the EMacs mode, but I'm unable to launch my code 
inside it. I also have a etexteditor bundle for Rebol.
Steeve:
8-Feb-2009
i don't like colorization of code, so that a simple text editor with 
macros (to launch rebol) is enough
Janko:
8-Feb-2009
hm.. I think you have to a line to your .emacs file .. just a sec
Anton:
8-Feb-2009
kib2: I should point out that  '  is not an operator. There are a 
few word datatypes which are closely related, but are treated slightly 
differently.
	word!     eg.    hello
	lit-word!  eg.   'hello
	get-word! eg.  :hello
	set-word! eg.  hello:
kib2:
8-Feb-2009
I saw there was a really nice postscript (and pdf) lib in Rebol. 
What about using it for making scientific diagrams ? (an old project 
of mine, in Python, was geoPyx here: http://kib2.free.fr/geoPyX/geoPyXfr.html)
kib2:
8-Feb-2009
Anton: so what is ' exactly ? I mean a litteral, but that's not a 
Rebol function ?
Anton:
8-Feb-2009
No, not a function.
Anton:
8-Feb-2009
When the interpreter evaluates some items in a block, and it comes 
across word!, it automatically tries to reduce it to its associated 
value.
Geomol:
8-Feb-2009
In the classes in astronomy, we're taught a language called IDL to 
reduce scientific data and make images and diagrams. I often just 
use REBOL directly to make the diagrams. I've wanted many times to 
make a library of routines or a plotting application in REBOL, but 
haven't had the time yet. Maybe some day.
Anton:
8-Feb-2009
When it comes across a lit-word!, however, it reduces it to the word! 
of the same spelling.
kib2:
8-Feb-2009
Geomol: is creating a plotting dialect that hard ?
Steeve:
8-Feb-2009
try this Kib:
>> a: 2
>> reduce [a]
>> reduce ['a]
Steeve:
8-Feb-2009
and
>> reduce reduce ['a]
Henrik:
8-Feb-2009
I wouldn't mind being able to set 3-4 months aside to create a complete 
graphing dialect.
kib2:
8-Feb-2009
Steeve: ok i've tried. But why the reduce output is a block ?
Anton:
8-Feb-2009
(kib2: yes, creating a plotting dialect is hard. It must be - I tried 
creating a general plotting function. There are many types of chart/graph 
to support.)
Geomol:
8-Feb-2009
kib, it's probably not hard, maybe take a bit of work to make it 
really slim and clever. I just have a ton of projects in the air 
all the time, so I didn't come to it yet.
Steeve:
8-Feb-2009
Kib because the input of reduce is a block
Anton:
8-Feb-2009
That is simply how reduce works. If you want a single value output, 
then use DO, which returns the last evalated value in the block.
	do ['a]
kib2:
8-Feb-2009
in fact it's logical : everything is a block.
Henrik:
8-Feb-2009
REDUCE is one of several block manipulation functions. It evaluates 
anything that can be evaluated inside a block.
Steeve:
8-Feb-2009
even, you can do 
>> reduce 'a
Anton:
8-Feb-2009
Yes, if you type something in the console, eg:

	print 1 + 2


you can imagine that it takes the string "print 1 + 2", LOADS it 
into a block, [print 1 + 2], then DOes it.
Anton:
8-Feb-2009
DO is like REDUCE, in that it evaluates every item in the block, 
except DO does not create and store results in a new block - it just 
returns the last value.
Anton:
8-Feb-2009
You can't really say that in rebol everything is a block, but you 
can say everything is *in* a block. Most rebol code is found in blocks. 
Blocks rule as the container of choice in the rebol universe!
Anton:
8-Feb-2009
- Create references to parts of datatypes. Eg. Make a variable which 
aliases the y component of a pair!
Steeve:
8-Feb-2009
Hum, we can with tiny functions accessors, the drawback is that it's 
more slow than a real reference
Anton:
8-Feb-2009
A pair! is a datatype which looks like a series, but is unfortunately 
(for this case) a scalar. That means any modification causes the 
whole pair to be copied.
kib2:
8-Feb-2009
I think I've found a good exercice...if only the following is true 
: Rebol seems to handle prefix notation
Anton:
8-Feb-2009
A negate.
Steeve:
8-Feb-2009
beware with same? it's not really a math operator
Geomol:
8-Feb-2009
>> [a b c] = [a b c]
== true
>> [a b c] == [a b c]
== true
>> [a b c] =? [a b c]
== false
Geomol:
8-Feb-2009
REBOL is like a little magical mountain lake. It doesn't look much 
on the surface, but it's soo deep.
Steeve:
8-Feb-2009
yes Kib2 but the doc is incomplete, == is also case sensitive
>>"a" = "A"
==true
>>"a" == "A"
==false
Geomol:
8-Feb-2009
kib, you can implement complex numbers as two numbers inside a block.
Geomol:
8-Feb-2009
kib, I've made a little library for complex numbers, if you like.
Geomol:
8-Feb-2009
http://www.fys.ku.dk/~niclasen/rebol/libs/math/complex.r

Just a little start, and no documentation, so you have to read the 
code to figure it out.
kib2:
8-Feb-2009
So i have a difficult question : how do you handle intersection(s) 
between two paths ?
Geomol:
8-Feb-2009
kib, :-D
Do you expect me to remember, how postscript works. ;-)
I have to think a bit now ...
kib2:
8-Feb-2009
i meant ie is there something for computing intersection between 
a line and a bezier path ?
Steeve:
8-Feb-2009
better to know how to use a search engine (like google) instead of 
trying to remember all the url ;-)
Anton:
8-Feb-2009
kib2, you mean intersection(s)* between a line and a bezier path.
Anton:
8-Feb-2009
It must be a fairly complex algorithm..
kib2:
8-Feb-2009
Anton: yes, that's why I was asking if someone else already wrote 
something like that. Computing such things much be a real headache 
!
Geomol:
8-Feb-2009
kib, I took a look at the PS documentation, and it has arcs, curves, 
etc. This isn't implemented in the REBOL ps dialect (yet). My dialect 
was just make fast to get some useful postscript out from REBOL.


I have a book on computer graphics, that might deal with the problem, 
you describe. I take a look ...
Steeve:
8-Feb-2009
you should be well informed, it's a dark matter
kib2:
8-Feb-2009
Geomol: Worth a look ?
Geomol:
8-Feb-2009
Just realized, David H. Eberly is also the author of a book called 
"3D Game Engine Design". I should get this.
kib2:
8-Feb-2009
Steeve :  the purpose is to create a geometrical drawing dialect. 
Maybe I'll have a line (AB) that intersects an ellipsis and I wanted 
to use the intersection points
Geomol:
8-Feb-2009
LOL again! I was just about to say:


ah, intersection of a line and an ellipse, then you just have to 
go to Anton's library.
Geomol:
8-Feb-2009
Anton, that's a really cool demo with the line and ellipse!
Anton:
8-Feb-2009
Note: I did not solve the "nearest point on an ellipse to a given 
point" problem yet, which is hard, so the auto-selection of nearest 
control point is not perfect.
Geomol:
8-Feb-2009
About intersect of line and polynomial curve.
There's a preview of the book, I was talking about here:

http://books.google.com/books?id=82kntxqd1BoC&printsec=frontcover&dq=Geometric+Tools+for+Computer+Graphics#PPA250,M1
Geomol:
8-Feb-2009
The author, David Eberly, also has a lot of online documentation:
http://www.geometrictools.com/Documentation/Documentation.html

Look under "Intersection".
Geomol:
8-Feb-2009
Some use COMPOSE, that will return a block:

>> compose ["Date:" (now/date) "Time:" (now/time)]
== ["Date:" 8-Feb-2009 "Time:" 23:21:57]

That you can turn into a string with useful spaces by:

>> form compose ["Date:" (now/date) "Time:" (now/time)]
== "Date: 8-Feb-2009 Time: 23:21:08"
Geomol:
8-Feb-2009
If you just wanna print the result, PRINT can work on a block, which 
will be reduced and spaces included in the output:

>> print ["Date:" now/date "Time:" now/time]
Date: 8-Feb-2009 Time: 23:24:27
Geomol:
8-Feb-2009
This will create a hashtable, that works like a block, but is faster:

>> table: make hash! [a 1 b 12 c 4 d 65]
kib2:
8-Feb-2009
Geomol: and thanks a lot for your help
Geomol:
8-Feb-2009
lol :-)
it's ok, I'll go to bed in a moment.
Geomol:
8-Feb-2009
You can read a short intro to hash tables here: http://www.rebol.com/docs/core23/rebolcore-16.html#section-2.5
kib2:
8-Feb-2009
where format is a function I've written.
Geomol:
8-Feb-2009
REBOL has a build-markup function.
Geomol:
8-Feb-2009
>> build-tag [a b 1]
== <a b="1">
kib2:
8-Feb-2009
a: 1
kib2:
8-Feb-2009
build-markup "toto<%a%>"
Geomol:
8-Feb-2009
It seems, it does, if you do it like this:


>> t: make hash! compose [a (make hash! [a 43 b 34]) b (make hash! 
[a 34 b 87])]
== make hash! [a make hash! [a 43 b 34] b make hash! [a 34 b 87]]
>> type? t/2
== hash!
>> t/b
== make hash! [a 34 b 87]
>> t/b/a
== 34
Izkata:
8-Feb-2009
When you mentioned it was faster, I got curious, as I need speed 
for some data mining algorithms I'm implementing in Rebol for a class
Geomol:
8-Feb-2009
A simple timing function to test performance:

time: func [:f /local t][
    t: now/time/precise
    do f
    now/time/precise - t
]
Janko:
8-Feb-2009
it is normal that hash! will only hash "keys" of assoc on first level, 
if you want on sublevels you can iterate the list and turn it into 
hashes acordingly .. if you have a lot of data hash is a lot faster 
650x in this test http://www.rebol.com/article/0020.html
Janko:
8-Feb-2009
kib2: technically , that is not a function but a block of code (which 
is very usefull) :) .. sorry to be a smartass
Geomol:
8-Feb-2009
kib, like "Easy VID"? Go to ViewTop and REBOL.com/Demos/Easy VID

When you read a page, you can click the code and see how it evaluate.
Geomol:
8-Feb-2009
The whole Easy VID is a 15.1 kb script. You can right-click an icon 
on the ViewTop to see source, size, etc.
kib2:
8-Feb-2009
Geomol: no, I mean something to write documentations for a rebol 
lib.
kib2:
8-Feb-2009
2 secs, I'm making a screenshot
Geomol:
8-Feb-2009
Ok, got it. Carl use MakeDoc to make his documentation, I use NicomDoc 
(my version of MakeDoc). I don't know of a tool, that can show you 
the result, while you type.
Geomol:
8-Feb-2009
kib, so that's a good project for you! :-)
Geomol:
8-Feb-2009
Maybe someone wrote a HTML viewer in REBOL? You could try search 
the library: http://www.rebol.org/
Henrik:
8-Feb-2009
there is limited freedom in VID for that in that each face must have 
one style, so if you want to render large chunks of formatted text, 
it may be a bit slow. this is solved in REBOL 3.
Henrik:
8-Feb-2009
in R3, the DOC style is a miniaturized makedoc.
DideC:
9-Feb-2009
I also give it a try. Not really a browser, just an HTML renderer 
with view/draw.

But rendering HTML is a very complex thing to do, especially the 
layout, tables...
So it is only able to render texte styles.
Henrik:
9-Feb-2009
In the long run, it's probably better to adopt something like webkit. 
Creating a good HTML rendering engine is a monstrous task, but I 
would like to see an extension of the DOC style for good document 
reading.
DideC:
9-Feb-2009
Yeah, DOC style is a good start.

But there are already great things with R2 : remembering HyperNotes 
(In R2 Desktop, rebol.com, Contest) this is a Makedoc based and rendering 
is just fine, with links and so on !!
DideC:
9-Feb-2009
It could be a good base for a remote Wiki editor. Just add an HTML 
generator to convert to static pages tree.
23601 / 6460812345...235236[237] 238239...643644645646647