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

World: r3wp

[!REBOL3-OLD1]

btiffin
7-Jan-2009
[9254]
a comma would be lexically foreign!
BrianH
7-Jan-2009
[9255]
I was typing in English, not REBOL. There's a difference.
Chris
7-Jan-2009
[9256]
Need the Rebolish group for contrast (if it's still around...)
BrianH
7-Jan-2009
[9257]
If I had known English and REBOL the same amount of time, I would 
be able to read REBOL quicker because the rules are stricter, and 
because I wouldn't have to look for periods and commas. This goes 
more so for C-like syntax - even slower to read.
Maxim
7-Jan-2009
[9258]
brian, I think everyone is just talking about a standardized, way 
to load human-readable data.  we know its not REBOL data.
BrianH
7-Jan-2009
[9259]
On my current screen I can barely see periods and commas in AltMe 
(netbook).
btiffin
7-Jan-2009
[9260]
Why can't junk be REBOL data, with semantics of junk!  ??
Maxim
7-Jan-2009
[9261]
If can tell someone that he can use his "CURRENT" data directly within 
rebol, there is a chance he'll actually try it out..
btiffin
7-Jan-2009
[9262]
Ahh, the point exactly.  ;)
Maxim
7-Jan-2009
[9263x2]
we aren't talking about code, we are talking about DATA.
I think we should have a function called 'ASSIMILATE.
BrianH
7-Jan-2009
[9265]
Maxim, I agree with you! I just remember that LOAD is for loading 
REBOL data, not human data. We should have standard functions for 
parsing human data, localized. But there are real disadvantages to 
making LOAD that function.
Maxim
7-Jan-2009
[9266]
which is even more semantically exact than import.
Steeve
7-Jan-2009
[9267]
it's not the only one problem, the need to parse data previously 
only to remove such junks reduce the overall performance of our scripts
Maxim
7-Jan-2009
[9268]
and the new name is... REBORG    ;-)
Graham
7-Jan-2009
[9269]
LOL
BrianH
7-Jan-2009
[9270]
For that matter, every option added to a function is an option that 
needs to be checked at runtime. That has overhead too.
btiffin
7-Jan-2009
[9271]
Steeve; I'm not bringing up this point for OUR scripts, it' grandma's 
and Joe the Plumbers.
Steeve
7-Jan-2009
[9272]
are the republicans allowed to use our fabulous REBOL ?
BrianH
7-Jan-2009
[9273x2]
If you want to make a grandma language, good for you. I say language 
instead of dialect because changing the syntax changes the langage 
- dialects use thee same data syntax, that is where they get their 
speed.
Steeve, I'm sure we have Republicans in the community (Paul?) :)
xavier
7-Jan-2009
[9275]
lol
btiffin
7-Jan-2009
[9276]
Do you not see the simplicity of foreign! data?   No speed problems, 
the lexical gets to a point where it would throw and it stashes a 
foreign!, keeps on truckin'.
BrianH
7-Jan-2009
[9277]
Here's the current source for LOAD:

load: func [
	{Loads a file, URL, or string.}
	source [file! url! string! any-block! binary!]

 /header  {Includes REBOL header object if present. Preempts /all.}

;	/next    {Load the next value only. Return block with value and 
new position.}

;	/library {Force file to be a dynamic library. (Command version)}
;	/markup  {Convert HTML and XML to a block of tags and strings.}
	/all     {Load all values. Does not evaluate REBOL header.}
	/unbound {Do not bind the block.}
	/local data tmp
][
	; Note: Avoid use of ALL func, because of /all option
	if any-block? :source [return :source]

	data: case [
		string? source [to-binary source]
		binary? source [source]
		; Check for special media load cases: (temporary code)
		find [%.jpg %.jpeg %.jpe] suffix? source [
			return load-jpeg read/binary source
		]

  url? source [read source] ; can this possibly return not binary! 
  ?
		file? source [read source] ; binary! or block of file!
	]

 ; At this point, data is binary!, a block of file!, or something 
 weird.

	if binary? :data [
		unless find [0 8] tmp: utf? data [
			cause-error 'script 'no-decode ajoin ['UTF tmp]
		]

		; Only load script data:
		if any [header not all] [ ; Note: refinement /all
			if tmp: script? data [data: tmp]
		]
	]

	unless block? :data [data: to block! :data] ; reduce overhead

 ; data is a block! here, unless something really weird is going on
	tmp: none
	
	; Is there a REBOL script header:
	if any [header not all] [ ; /header preempts /all
		tmp: unless any [

   ;not any [file? source url? source] ; removed: hdr in string is same
			unset? first data ; because <> doesn't work with unset!
			'rebol <> first data
			not block? second data
		][ ; Process header:
			attempt [construct/with second data system/standard/script]
		]
		; tmp is header object or none here
		case [
			tmp [
				remove data
				either header [change data tmp][remove data]
				tmp: tmp/type = 'module ; tmp true if module
			]
			header [cause-error 'syntax 'no-header data]
		]
	]
	; tmp is true if module, false or none if not

 ; data is a block!, with possible header object in first position

	; Bind to current global context if not a module:
	unless any [
		unbound
		tmp ; not a module
	][
		bind/new data system/contexts/current
	]

 ; data is a block! here, unless something really weird is going on

	; If appropriate and possible, return singular data value:
	unless any [ ; avoid use of ALL
		all
		header ; This fixes a design flaw in R2's LOAD
		;not block? :data ; can this ever happen?
		empty? data ; R2 compatibility
		not tail? next data
	][data: first data]
	; If /all or /header, data is a block here

	:data
]
Maxim
7-Jan-2009
[9278]
hell, I even have a "I LOVE BUSH" day every year... I'm 1/365 republican 
!
Steeve
7-Jan-2009
[9279]
argh..... my screen exploided...
Maxim
7-Jan-2009
[9280x2]
and I'm not even American!
;-)
xavier
7-Jan-2009
[9282]
brian, is there another function that is specified for loading human 
data ?
btiffin
7-Jan-2009
[9283]
Adding foreign! doesn't really change LOAD does it?  It changes the 
native  make  phase  no?
BrianH
7-Jan-2009
[9284]
We don't want foreign! by default though (or ever, but that is another 
matter), and you can't provide options to TO. We would have to support 
foreign!, or better yet fallback, incrementally with TRANSCODE.
Chris
7-Jan-2009
[9285]
Quick 'n' dirty 'load-junk (cvts: for R2; junk! is string!; blocks 
mess things up): http://www.ross-gill.com/r/load-junk.r
BrianH
7-Jan-2009
[9286]
See, that is what we need! A separate function.
Chris
7-Jan-2009
[9287x3]
Ignores comments!
Agreed Mr. B.
comments == commas...
BrianH
7-Jan-2009
[9290x2]
Look how complex LOAD is already. That is why it is now mezzanine: 
The complexity is better handled by REBOL code.
It's still fast though :)
Graham
7-Jan-2009
[9292]
Chris, 404s for me
Steeve
7-Jan-2009
[9293]
hum... Brian, switch is not faster than case in load ?
Chris
7-Jan-2009
[9294]
Hmm, that'd be http://www.ross-gill.com/r/junk.r
BrianH
7-Jan-2009
[9295x2]
Nope, case is one of the fastest functions in REBOL, even R2.
We profile everything :)
Steeve
7-Jan-2009
[9297]
i know for R2, but in R3 switch is native, no  ?
btiffin
7-Jan-2009
[9298]
Ok, I'd gladly accept a separate function, but ship it with REBOL 
for grandma and the professors of the world.  Don't make them hunt 
it down and DO it as a special case.    But to be honest, I'd still 
prefer a foreign! datatype! and advertise REBOL as a human readable 
language.  Much power in that ad imho.
Maxim
7-Jan-2009
[9299]
but we also need an unknown!  ,   junk!  ,   or  WTF!   datatype 
   ;-)    

note the intentional use of commas  ;-)
BrianH
7-Jan-2009
[9300x2]
Switch is native in R2 as well.
At least for the last few years.
Steeve
7-Jan-2009
[9302]
not in the version i use, sigh...
btiffin
7-Jan-2009
[9303]
Maxim;  And let cunning linguists write some scripts that tally the 
amount of WTF! information in wikipedia.   ;)