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

World: r3wp

[World] For discussion of World language

Geomol
6-Dec-2011
[437x2]
ok, I think, most believe, LLVM/Clang is about performance.
So it's more about portability and maybe better error messages?
Andreas
6-Dec-2011
[439]
For typical end-users, clang is about fast compilation and good error 
diagnostics (at the moment).
Geomol
6-Dec-2011
[440]
ok,thanks
Andreas
6-Dec-2011
[441]
Clang also explicitly aims at GCC compatibility, so switchting to 
it from GCC is generally rather easy.
Steeve
6-Dec-2011
[442]
I'm confused Geomol, you're not aiming LLVM to perform jit within 
#world  but to compile the VM of #world ?
Andreas
6-Dec-2011
[443]
Yes.
Steeve
6-Dec-2011
[444]
but...

what is the interest, I mean when compared with standard C compilation.
Andreas
6-Dec-2011
[445]
That is just standard C compilation :)
Steeve
6-Dec-2011
[446]
uh !
Andreas
6-Dec-2011
[447x2]
LLVM/Clang is actually the default toolchain in Xcode4, for example 
:)
IIUC, John tried LLVM to see if the resulting binaries would performan 
better than GCC-compiled ones.
Steeve
6-Dec-2011
[449x2]
ah ok, but is there any other motivation behind the scene like to 
be able to compile code on the fly instead of generationg bytecodes 
for the VM ?
I mean LLVM can support JIT or is that another toolchain ?
Andreas
6-Dec-2011
[451x2]
LLVM can also be used as a set of compilation libraries, yes. And 
you can implement a JIT that way, yes.
But they also provide a set of ready-built binaries which work as 
a nice AOT compiler for C/C++/ObjC. I.e. just like GCC or MSVC or 
ICC or ...
Kaj
6-Dec-2011
[453]
John, you may want to try -Os. Optimising for size often leads to 
best speed, too, on modern architectures due to caching efficiency. 
OS X is also compiled that way
Geomol
7-Dec-2011
[454x2]
Thanks, Kaj. I will try that.
Steeve, it was just to try another compiler.
World should accept REBOL [] as header to run R2, R3 scripts through 
it without editing these.

For now, it's possible to run REBOL scripts with this function:
do-rebol: func [file][do skip load file 2]
BrianH
7-Dec-2011
[456x2]
R3 scripts only require the REBOL header if they're modules/extensions.
Or when you want to put documentation before the header, or embed 
the script in a block in another type of file.
Geomol
7-Dec-2011
[458]
Ok, worth to consider.
BrianH
7-Dec-2011
[459]
That's why you don't need to write the REBOL header at the command 
line, even though those commands are just passed to DO like any other 
script :)
Geomol
7-Dec-2011
[460x5]
Kinda the same in World with the command line.
New release at https://github.com/Geomol/World
- Gave series an overhaul, so compiling blocks should really work 
now. Let me know, if it doesn't.
- Changed system/version/platform, so it's now a word.
- Added new tests.
When compiling blocks, each block instance has its own compiled code. 
And changing at one instance doesn't reset compilation for another 
(which would else add overhead). So:

w> s: [1]
== [1]
w> do s
== 1
w> t: tail s
== []
w> insert t 2
== [2]
w> do t
== 2
w> s
== [1 2]
w> do s
== 1


APPEND doesn't change at the block instance, so APPEND doesn't reset 
compilation.
Block compiled state will be reset by functions such as INSERT and 
REMOVE. And if the block is set to another location (NEXT/BACK with 
call-by-word for example).
Oldes
7-Dec-2011
[465]
What would be World's equivalent of this:    with: func[obj body][do 
bind body obj]
Geomol
7-Dec-2011
[466x4]
You found a bug! :) Uploading fix ...
@Oldes, fix uploaded. Get world_* again.
And the WITH function would then be:

with: func [obj body] [do compile/at body obj]
I added WITH to rebol.w
Andreas
7-Dec-2011
[470x3]
APPEND not resetting compilation while INSERT resets compilation 
is kind of weird (even though the implementation details leading 
to that decision may be understandable).
A helper function to reset compilation state would probably be helpful.
(Not sure if just calling COMPILE w/o context after modification 
would always be the same. Will have to think about it a bit more, 
but I have a hunch that it is not.)
Geomol
7-Dec-2011
[473]
Yes, I agree to some degree. If APPEND was a native, it would really 
make sense (I guess). We could add a compile to the APPEND mezzanine.


I think, the compilation reset would just be COMPILE. Don't you think?
Andreas
7-Dec-2011
[474x2]
No, I don't think so. The result will differ if something used in 
the block is redefined _after_ the block was modified.
A basic example:
c: copy []
f: func [x] [x]
append c [f 10 20]
;; recompiling c here, do c would == 20
f: func [x y] [x * y]
;; recompiling c here, do c would == 200
Geomol
7-Dec-2011
[476]
That code leads to an error, if c is compiled before f is redefined. 
The error system isn't very good atm., and I'll probably work on 
that next.


I need more experience with World and more examples to say, if a 
compile reset is a good idea.
Andreas
7-Dec-2011
[477x2]
You can also do it the other way round, then it won't lead to an 
error (at the moment, that is :)
So:
c: copy []
f: func [x y] [x]
append c [f 10 20]
;; recompiling c here, do c would == 10
f: func [x] [x]
;; recompiling c here, do c would == 20
Geomol
7-Dec-2011
[479]
Correct. World is not designed to cope with such cases, where words 
changes from functions taking arguments to passive non-function values, 
or if number of arguments changes to a function. To change the behaviour 
of the c block, a compile is needed. So question is, if that compile 
should be executed by a COMPILE call, or if the compile state of 
the block could be reset, and in this case, it would be compiled, 
the next time, it was executed with DO.
Andreas
7-Dec-2011
[480x2]
Currently we have a way to force (re)compilation (with COMPILE), 
but we don't have a way to drop previous compilation.
The example above illustrates that for the most general case, both 
are needed.
Geomol
7-Dec-2011
[482]
Right, and we have to figure out, if we really need that.
Andreas
7-Dec-2011
[483]
I am a strong believer that in cases such as this, whatever is helpful 
internally should also be exposed at the user-level.
Geomol
7-Dec-2011
[484]
My personal view is, that it's sort of bad programming practise to 
change number of arguments to a function in the middle of a program, 
or to change a work from meaning a function or operator to meaning 
e.g. a number.


But I think, it's possible to cope with such strange situations, 
because we have COMPILE.
Andreas
7-Dec-2011
[485x2]
I.e. as INSERT is able to _reset_ compiled state, so should be the 
user.
(Then a mezzanine APPEND could just reset compiled state, and would 
behave identical to INSERT in that aspect.)