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

World: r3wp

[!REBOL3 Schemes] Implementors guide

Graham
5-Jan-2010
[45x2]
how does that work?  Is it like a dictionary space in forth?
which allows you to define where to look for words and in what order 
the dictionaries are searched
BrianH
5-Jan-2010
[47x2]
LOAD/header. All of the module requirements/exports are in the header. 
Even Carl's proposed export keyword will be handled like FUNCT - 
at load time, not runtime.
In the case of FUNCT uses in the mezzanine source, the code is run 
and then saved, so there is no FUNCT calls at startup time.
Graham
5-Jan-2010
[49]
So, say we had a module containing all the charset definitions .. 
how would we include them to be accessible to us at run time?
BrianH
5-Jan-2010
[50]
You would include Needs: [charsets] in the header of the organizing 
script of your project. If we do it right, we might even be able 
to selectively import the words, though that might need some thought 
for loaded charsets - I'll give it some thought later, as mixins 
are currently file-based. I have an idea about how to do it though, 
in the preprocessor.
Graham
5-Jan-2010
[51x2]
Ok.
And there's this in prot-http.r

crlfbin: #{0D0A} 
crlf2bin: #{0D0A0D0A} 
crlf2: to string! crlf2bin 

This stuff should be in some reusable module too
BrianH
5-Jan-2010
[53x2]
prot-http.r is itself a reusable module.
I think that the preprocessor will actually mix in the mixins itself, 
as if they were part of the original source of the calling modules. 
That way if you want to do selective import you would split your 
module into two, one that contains the shared stuff, and another 
that contains the local stuff that references the shared module. 
It's not as hard as it sounds.
Graham
5-Jan-2010
[55]
maybe instead of make-scheme there could be something like make-network-scheme 
where these are automatically accessible?
BrianH
5-Jan-2010
[56]
How about let's worry about the refactoring later, and focus on getting 
it to work now. We can refactor on the way.
Graham
5-Jan-2010
[57x2]
still leads to duplication of code
yeah .. always put off today what can be done tomorrow :)
BrianH
5-Jan-2010
[59]
Which we can deduplicate during the refactoring :)
Graham
5-Jan-2010
[60]
Kaj raised the point of how much memory r2 and r3 take compared with 
the clone ...
BrianH
5-Jan-2010
[61]
Yes, another point for the refactoring. The clone doesn't do as much 
though.
Graham
5-Jan-2010
[62x4]
read and write are very similar ... can we do this?

		read: func [
			port [port!]
			/write data
		] [
			either any-function? :port/awake [

    unless open? port [cause-error 'Access 'not-open port/spec/ref] 
				if port/state/state <> 'ready [http-error "Port not ready"] 
				port/state/awake: :port/awake 
				do-request port 
				port
			] [
				sync-op port either write [ data ] [[]]
			]
		] 
		write: func [
			port [port!] 
			value
		] [

   unless any [block? :value any-string? :value] [value: form :value] 

   unless block? value [value: reduce [[Content-Type: "application/x-www-form-urlencoded; 
   charset=utf-8"] value]] 
			read/write port data 
		]
should be

read/write port [parse-write-dialect port value]
well... can't use /write as the refinement .. but the idea ...
heh ..Gabriele must be top down programming .. .he writes the higher 
order code first and then the supporting definitions.
BrianH
5-Jan-2010
[66]
He programs in the RLP and then it topologically sorts the code.
Graham
5-Jan-2010
[67]
Dunno what that means .. but it's the same in the rlp
BrianH
5-Jan-2010
[68]
Ah, less topological sorting than I thought.
Graham
5-Jan-2010
[69x3]
Which is the latest ... prot-http.rlp or prot-http.r ?
later ..
ie. is prot-http.r generated from the rebol literate programming 
document?
BrianH
5-Jan-2010
[72x2]
prot-http.r is the latest. prot-http.rlp was just uploaded later.
The original prot-http.r was generated from .rlp, but has since been 
revised directly. Look at the revision history with LF and DIFF.
Graham
5-Jan-2010
[74x2]
ok,  I see this

        spec/headers: third make make object! [
in the rlp, and in the .r

	spec/headers: body-of make make object! [
so they are different.
BrianH
5-Jan-2010
[76]
body-of would work, third wouldn't.
Graham
5-Jan-2010
[77x2]
so the rlp is correct?  and the .r is not ?
reverse that ...
BrianH
5-Jan-2010
[79]
The .rlp version is more than 2 years old, the .r is more recent 
and works.
Graham
5-Jan-2010
[80]
oh ...ok.
BrianH
5-Jan-2010
[81]
works, sort-of, still needs work.
Graham
5-Jan-2010
[82]
spec/headers: body-of make make object! [
		Accept: "*/*" 
		Accept-Charset: "utf-8" 
		Host: either spec/port-id <> 80 [
			rejoin [form spec/host #":" spec/port-id]
		] [
			form spec/host
		] 
		User-Agent: "REBOL"
	] spec/headers 
what exactly is this code doing?
BrianH
5-Jan-2010
[83x2]
Makes a object containing the standard http headers derived from 
the template object, also defined in a literal spec.
Has an extra object of overhead.
Graham
5-Jan-2010
[85]
so spec/headers contains the standard template, and it adds these 
other members to this template?
BrianH
5-Jan-2010
[86x2]
Yeah, I think so. I shoud check for sure. This is why I am starting 
woth mezz-ports.r first.
Something looks reversed, like spec/headers is using the specific 
headers as a template rather than the reverse. Don't know why yet.
Graham
5-Jan-2010
[88x3]
So, it is modifying the original spec/headers by adding these new 
members to spec/headers ...  as a way of modifying the object in 
situ as it were
I wonder why he can't do this 

spec/headers: make spec/headers [
		Accept: "*/*" 
		Accept-Charset: "utf-8" 
		Host: either spec/port-id <> 80 [
			rejoin [form spec/host #":" spec/port-id]
		] [
			form spec/host
		] 
		User-Agent: "REBOL"
]
oh ... headers is a block and not an object!
BrianH
5-Jan-2010
[91]
I think that the Accept, Accept-Charset and User-Agent headers are 
the defaults, and spec/headers are the user-specifiable options.
Graham
5-Jan-2010
[92]
So he is using make object! to ensure that he has unique members 
in the created block!
BrianH
5-Jan-2010
[93]
Actually, an object is created. Then it is converted to a string 
later.
Graham
5-Jan-2010
[94]
Yeah .. seems a rather round about way of doing things.