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

World: r3wp

[!REBOL3 Schemes] Implementors guide

Graham
7-Jan-2010
[245x3]
It looks like termites have been thru it http://www.rebol.net/wiki/Schemes:Notes
so many gaps in it
If Carl wants community involvement .. the docs need to get better 
....
Maxim
7-Jan-2010
[248]
docs are PART OF community involvment.
Graham
7-Jan-2010
[249]
Name one person in the community who could write this document ...
Maxim
7-Jan-2010
[250]
sorry I should have put a bit more meat in my message... this doesn't 
apply to this specific page but to all of REBOL documentation (especially 
R3).  


There doesn't seem to be anyone interested in taking charge of the 
documentation.


AFAICT, I'm not sure people realize that Carl does expect the community 
to be a big player in the documentation. 


this is more a constatation than criticism.  I don't know how it 
plays out in Open source language communities, but it seems to me 
that there is always a little gang which ends up being the documentation 
krew... seems we lack this fiber in our community.
Steeve
7-Jan-2010
[251]
Graham, a scheme less guy
Maxim
7-Jan-2010
[252x2]
but a few of us could contribute to schemes... a few of us have actually 
written schemes... there also was a great tutorial on rebol forces 
about schemes.   maybe that could be used as the basis for this page.
note ... this is an R2 page.
Graham
7-Jan-2010
[254x4]
Note, I referenced a R3 page on schemes
This is hereby declared a R2 free zone
I've had a go at this the simplest of schemes and can't get it working 
... 

http://rebol.wik.is/Rebol3/Schemes/Daytime
I grabbed stuff from Carl's demos and Gabriele's http protocol
Steeve
7-Jan-2010
[258]
it's normal. you don't open any tcp port
Graham
7-Jan-2010
[259x3]
eh?
I try this

read daytime://time-a.nist.gov
It says the port gets opened but the awake function is not triggered
Steeve
7-Jan-2010
[262x3]
yes but your actors (open and/or read) must create a tcp port thru 
the host
a scheme is only a wrapper above a tcp connection
(or upd)
Graham
7-Jan-2010
[265]
I know ..
Steeve
7-Jan-2010
[266]
So you have to do a open tcp://host somewhere in your code
Graham
7-Jan-2010
[267]
Oh ... I didn't create the port ...
Steeve
7-Jan-2010
[268]
yes
Graham
7-Jan-2010
[269]
ok, it will have to wait till my tv program finishes now
Steeve
7-Jan-2010
[270x2]
give me some minutes, i will write it
make-scheme [
	name: 'daytime
	title: "Daytime Protocol"
	awake: func [event /local port] [
		print ["=== Client event:" event/type]
		port: event/port
		switch event/type [
			lookup [
				print "DNS lookup"
				open port
			]
			connect [
				print "connected" 
				read port
			]
			read [
				close port
				return true ; quits the awake
			]
		]
		false
	]
	actor: [
		;open: func [port [port!]][port]
		read: func [
			port [port!] /local con
		][
			con: open rejoin [tcp:// port/spec/host ":13"]
			con/awake: :awake
			wait con
			to-string con/data
		]
	]
]

probe read daytime://time-a.nist.gov

=== Client event: lookup
DNS lookup
=== Client event: connect
connected
=== Client event: read
{
55203 10-01-07 07:51:23 00 0 0 282.6 UTC(NIST) *
}
Graham
7-Jan-2010
[272]
thanks
Steeve
7-Jan-2010
[273]
you may add a timeout inside the wait.
Graham
7-Jan-2010
[274x3]
can add it to the spec
I've updated my effort again ... http://rebol.wik.is/Rebol3/Schemes/Daytime
the data is returned deep inside the port object
Steeve
7-Jan-2010
[277x2]
weird !

The open function must not return the tcp port, but the fake daytime 
port.

Because if someone try to thing like this. 
>> port: open daytime://...
then 

>> read port ; ==> the wrong actor is called (not the daytime one).
it may work currently, because you didn"t add other behavior in the 
read actor, but it's just fluke
Gabriele
7-Jan-2010
[279x4]
brian: there is no link to wetan, it is in the r3-alpha file share.
(graham's link above is not complete. there are a few pieces missing, 
and they are missing because the code, even tough it works, is crap 
:)
documentation in the code itself using comments

 - that only works in very simple cases. I did the network detective 
 like that...
Maxim: sorry, I don't understand your point. the code is not available 
to us, so only Carl can write the basic docs...
Graham
7-Jan-2010
[283x4]
Steve ...good point.
Steeve ...
they can do ..

port: open daytime://
wait port 

:)
I've logged onto r3 chat a few times .. seems dead to me.
Pekr
7-Jan-2010
[287x2]
dead? it works, but noone is posting, no?
or you mean dead by activity?
Graham
7-Jan-2010
[289]
dead as in dead quiet
Pekr
7-Jan-2010
[290]
it is dead because all R3 dev. activity is stalled ....
Graham
7-Jan-2010
[291x2]
It is also quite hard to cut and paste as the console doesn't support 
it ..except as a dos console
Have to use the clipboard to transfer stuff to and from the r3 alpha 
console
Pekr
7-Jan-2010
[293]
yes, console under Windows is really bad ... also no multiline support 
for REBOL code ...
Graham
7-Jan-2010
[294]
Is it better under linux?