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

World: r4wp

[#Red] Red language group

Kaj
20-Aug-2012
[1066x4]
Encapped: perhaps for most people. But it's also good to be able 
to browse the source, especially the runtime at this early stage
R2 has always been rather nasty with the working directory, fiddling 
with it. I think R3 is better
I think it will definitely bring in more people if they don't have 
to install REBOL as well as Red. One less barrier, and REBOL has 
lots of problems with installation
The GTK binding works again
DocKimbel
20-Aug-2012
[1070]
Browse the runtime: agreed, but we could ease that by adding support 
for docstrings in functions and use them to auto-generate a reference 
doc for the runtime functions. I remember Peter suggesting me that 
months ago, maybe we could also start working on it now. I think 
that some minor modifications to functions spec block parsing rules 
should suffice. For other elements like namespaces, enums, aliases, 
we could allow an optional docstring somewhere to document them too. 
I can do the required modifications on the compiler quickly if someone 
is willing to write the docstrings?
PeterWood
20-Aug-2012
[1071]
I'll willingly help with the doc strings but am a bit short for time 
this week.
Kaj
20-Aug-2012
[1072x3]
Docstrings would be great
I already write the bindings as if they were there, with some REBOL 
style documentation in comments
I went through my bindings and simplified several by using SWITCH 
and CASE
DocKimbel
20-Aug-2012
[1075x3]
SWITCH and CASE not only simplify the source code, but they also 
significantly reduce the emitted code size.
Have you already enhanced your GTK dialect with namespaces and WITH?
Peter: thanks, then I'll add that to my todo-list.
Kaj
20-Aug-2012
[1078x2]
SWITCH and CASE: ehm, no. Each one makes the binary 16 to 24 bytes 
larger
Namespaces: not yet, I'm planning to do that after the release
DocKimbel
20-Aug-2012
[1080x3]
Peter: the lib-test file is crashing here on my OS X 10.6.2 image 
with following error:

dyld: lazy symbol binding failed: Symbol not found: _strnlen

  Referenced from: /Users/dk/Desktop/Red/red-system/tests/runnable/lib-test
  Expected in: flat namespace


After researching a bit about it, it seems that strnlen() is (was?) 
not supported by OS X.
SWITCH and CASE: I had a ~20% code reduction on Red/System runtime 
when I used them instead of tons of IFs. I guess your use-case is 
different.
It seems that strnlen() is defined for versions >= 10.7.0...unfortunately, 
I can't upgrade my image (virtual image), so I will replace strnlen() 
by strlen() in the tests.
Kaj
20-Aug-2012
[1083]
The constructions in the runtime you replaced were very inefficient. 
Normal EITHER constructions seem to have less overhead than SWITCH 
and CASE. It's more or less independent from the number of clauses. 
It may be the default clause, especially when one is needed in CASE
DocKimbel
20-Aug-2012
[1084]
After looking at the diff-ed code, I think that replacing all the 
assignment in IFs bodies, by a single one before the SWITCHs is what 
produced the code size gain.
Kaj
20-Aug-2012
[1085x3]
Yes, I did manage to make small gains where SWITCH could be used, 
but only when it makes other constructs obsolete. First you have 
to make good on the overhead of SWITCH itself
strnlen only available in last year's OS X? Oh man...
I suspect you could optimise SWITCH and CASE by detecting constant 
expressions, like C does, especially when TRUE is used as a default 
clause for CASE
DocKimbel
20-Aug-2012
[1088]
Probably, but we'll leave that for the final version of the compiler.
Kaj
20-Aug-2012
[1089]
I think
--assert 12 = strlen s 32
should be
--assert 12 = strlen s
in your last commit
DocKimbel
20-Aug-2012
[1090]
Thanks, forgot to commit that modification.
Andreas
20-Aug-2012
[1091x2]
Ah, so calling rsc.r from someplace else was the trouble.


Isn't that a fundamental problem with the current R2 interpreters? 
I seem to remember that when a script is running the interpreter 
already change-dir'ed to the directory containing the script, thereby 
losing the original working directory.
Anyone has an easy workaround for that handy?
DocKimbel
20-Aug-2012
[1093]
It's not lost, it should be stored in system/options/path.
Andreas
20-Aug-2012
[1094]
Reliably?
DocKimbel
20-Aug-2012
[1095]
I'm unsure about that.
Andreas
20-Aug-2012
[1096]
Time to try again, I guess :)
DocKimbel
20-Aug-2012
[1097]
So far, testing with a modified %rsc.r on Linux, it seems to be reliable.
Andreas
20-Aug-2012
[1098x3]
Do you use rsc.r from the REBOL console as well?
Well, seems to even properly work with DO.
(Testing with R2.7.8 on Linux.)
DocKimbel
20-Aug-2012
[1101]
Yes, from REBOL console.
Andreas
20-Aug-2012
[1102]
So `change-dir system/options/path` at the top of rsc.r it is :) 
?
DocKimbel
20-Aug-2012
[1103x2]
Not sure this would covers all cases.
We need two paths: one for locating red-system/ root directory and 
another one for the working directory.
So:
- system/script/path should give us red-system/ root
- system/options/path should give us working directory
Andreas
20-Aug-2012
[1105x2]
`do load %rsc.r` and DO-ing rsc.r from an URL are the two only cases 
I can think of right away where it might make not much sense (it 
would then use the workdir the REBOL interpreter was started.)
script/path & options/path: yes
DocKimbel
20-Aug-2012
[1107x2]
What we want is ability to call %rsc.r from anywhere, compiling a 
program from working dir (or relative to working dir) and producing 
the binary in the working dir.
(Kaj correct me if I'm wrong)
Andreas
20-Aug-2012
[1109]
Yes, that's what we want.
Kaj
20-Aug-2012
[1110]
Yes
Andreas
20-Aug-2012
[1111x3]
A minor question re the output binary remains: do we want to keep 
up the automatic executable name guessing we do at the moment (foo.reds 
-> foo || foo.exe), or do we want to use non-descript default name.
And if we want to keep the "nice" exe names (which would be my guess), 
what to do if the target file already exists?
Most developer friendly (imo): just overwrite it.
DocKimbel
20-Aug-2012
[1114]
Automatic name guessing: yes, we want to keep that and overwrite 
it if exists already.
Andreas
20-Aug-2012
[1115]
Ok, should be an easy change, but I guess the test runners will need 
adapting (if we want the new behaviour to be the default).