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

World: r3wp

[Red] Red language group

Gregg
25-Mar-2011
[599]
And...REALLY cool Bolek.
Dockimbel
25-Mar-2011
[600]
I first wrote 1MB, then I raised it thinking of possible libs that 
could get statically linked by users. But, it could be even easier, 
just hardcoding the DATA address offset somewhere in the CODE segment 
at linking time might be enough (no need to reserve fixed space in 
CODE segment).
Rebolek
26-Mar-2011
[601]
Another milestone reached ;) Now I get "segmentation fault" instead 
of "illegal instruction" :)
Dockimbel
26-Mar-2011
[602]
Have you defined a new runtime in red-system/runtime/ for OS X?
Rebolek
26-Mar-2011
[603]
Right now I just copied the Linux one.
Dockimbel
26-Mar-2011
[604]
Does OS X support the same syscalls?
Rebolek
26-Mar-2011
[605x2]
Yes. It's not recommended, but I think that for basic test it's enough.
http://www.opensource.apple.com/source/xnu/xnu-1504.3.12/bsd/kern/syscalls.master
Henrik
26-Mar-2011
[607]
are there specific CPU limitations? could this be done for, say, 
a 6502?
Dockimbel
26-Mar-2011
[608]
It requires 32-bit integer support for source compatibility with 
other platforms, but if you don't care about compatibility, it should 
be possible to make a 6502 emitter ;-)
Henrik
26-Mar-2011
[609]
ok
Dockimbel
26-Mar-2011
[610]
6502 is a bit far reach with its 8/16 bits architecture, but 68k 
should be doable while preserving all Red/System's features.
Henrik
26-Mar-2011
[611]
that would also be quite interesting.
Kaj
26-Mar-2011
[612]
I'd been phantasising about that, and about porting my 6502 emulator 
:-)
Rebolek
26-Mar-2011
[613]
porting 6502 emulator to 6502? :-)
Kaj
26-Mar-2011
[614]
If I would port the emulator and someone would do a 6502 backend, 
then yes :-)
TomBon
28-Mar-2011
[615]
doc, do you planing later external bindings features like SWIG / 
FFI  /ALIEN  etc ?
or would it be possible to access C/C++ libs directly with RED?
Kaj
28-Mar-2011
[616x4]
Red/System is a C level language, so you can just call C functions
Calling C++ requires a C wrapper for the C++ interface, as always 
with C++
Binding systems such as SWIG are way too heavy for Red, and C functions 
are neither foreign nor alien to Red/System, so FFI and ALIEN would 
be too heavy as well :-)
The only thing you have to do to call a C function is to translate 
the defintion of it in the C header to Red/System. It would be possible 
to write a C header parser to automate that process, one of the things 
that SWIG does. However, it would lead to ugly Red function definitions 
that don't make the most of the interface
Dockimbel
28-Mar-2011
[620]
Agreed with Kaj.
 

AFAIK, it might be possible to interface with C++ at very low-level, 
to be able to instanciate C++ objects and call their methods from 
Red. Same solution for obj-c interfacing, which will be required 
at some point to port Red to iOS.
TomBon
28-Mar-2011
[621]
thx, for info
Kaj
28-Mar-2011
[622x2]
That's in any case possible very naturally for Objective C. Io for 
example has a transparent Objective C bridge that allows accessing 
any Objective C object
For C++, you'd need RTTI to go in the direction of that level of 
transparency
Dockimbel
28-Mar-2011
[624]
Ruby has also a bridge to obj-c (I guess Python too).
Kaj
28-Mar-2011
[625]
The Io one is likely simplest, and BSD licensed, so you might be 
able to use some code from it
TomBon
28-Mar-2011
[626]
changing currently my serverbackends from rebol to luajit/FFI. what 
a relief and cool experience to just drop some c header inline and 

access the appropiate lib in seconds. the mapping is nice also.  
thought that this feature is quite important for Red.
Dockimbel
28-Mar-2011
[627]
Nice! We will see if we can come up with something even simpler with 
Red.
TomBon
28-Mar-2011
[628]
with the last beta you can detect also a real firework of new and 
planned very usefull bindings there.

a feature like this defines a real 'multipropose language' as I stated 
many times before.
Dockimbel
28-Mar-2011
[629]
I'll make sure that Red won't lag behind on that aspect. But, as 
Kaj says, binding to a library like SWIG might be overkill for Red, 
I'm pretty sure that we can come up with much shorter and better 
integrated solution for Red (remember that we will have PARSE support 
and ability to use dialects).
BrianH
28-Mar-2011
[630]
Objective-C messages can be passed with calls to C functions that 
are built into the runtime. All languages which have a different 
object model use these functions to interact with Objective-C in 
their compatibility layers. Internally, even Objective-C code compiles 
down to calls to these functions.
Dockimbel
28-Mar-2011
[631]
Good to know, seems easier at first look, to interface with than 
C++.
BrianH
28-Mar-2011
[632x3]
Interfacing with C++ functions and objects requires matching the 
name mangling and structure layout conventions, and those are different 
between compilers. There are some attempts to standardize these conventions, 
but their success is limited. This is why the developers of most 
Unix clones tend to hate C++. The best solution on most platforms 
tends to be to use C wrappers or one of the binary object interop 
standards like COM or CORBA.
Note that there is a typo in the manual you linked here: http://www.rebol.com/docs/core23/rebolcore-16.html#section-3.1
- the caret character is listed as #"^" when it should be #"^^".
Actually, almost all of those character literal examples are missing 
their leading ^.
Dockimbel
28-Mar-2011
[635x2]
Bad place for a typo.
Thanks for mentioning it, I've added a note in the specs about that.
BrianH
28-Mar-2011
[637x2]
It's an incomplete list too. Here is a complete list of the control 
characters (not including the keywords or hex in parens):

>> print mold collect [for x 0 255 1 [if 4 < length? mold to-char 
x [keep to-char x]]]

[#"^@" #"^A" #"^B" #"^C" #"^D" #"^E" #"^F" #"^G" #"^H" #"^-" #"^/" 
#"^K" #"^L" #"^M" #"^N" #"^O" #"^P" #"^Q" #"^R" #"^S" #"^T" #"^U" 
#"^V" #"^W" #"^X" #"^Y" #"^Z" #"^[" #"^\" #"^]" #"^!" #"^_" #"^"" 
#"^^" #"^~"]
That's in R2. In R3 it seems to be the same list, but #"^!" molds 
as #"^(1E)".
Kaj
28-Mar-2011
[639]
The new documentation is quite extensive. Is everything described 
(apart from the plans section) implemented, or not everything yet?
NickA
29-Mar-2011
[640]
Doc, the Red project has really sparked my hope for future REBOL 
development.  The following discussion is particularly exciting:


http://translate.google.com/translate?hl=en&sl=fr&tl=en&u=http%3A%2F%2Fwww.digicamsoft.com%2Fcgi-bin%2FrebelBB.cgi
Dockimbel
29-Mar-2011
[641x3]
Kaj: I've implemented 85-90% so far, I'll publish a list of missing 
features today.
Btw, anonymous comments are now allowed on the blog (I've left the 
captcha).
Nick: french talks passed through Google's translation service really 
do look weird...but the meaning seems mostly preserved. About Red, 
the potential is huge: draw a triangle with C, Lua and REBOL on each 
corner and put Red in the middle, you'll get a feeling of the possibilities. 
;-)
Pekr
29-Mar-2011
[644x2]
I want View for drawing triangles, not C or Lua :-)
But maybe you mean the possibility of rather easy usage of different 
targets/backend, and Red being  a glue language? Well, IIRC Reichart 
suggested REBOL being renamed to Glue, in the past. So will we have 
Red Glue? :-)
Rebolek
29-Mar-2011
[646]
But you have it: view [drawing 200x200 [triangle 0x0 200x0 100x200]] 
;)
Pekr
29-Mar-2011
[647]
Rebolek - does it work in Red? :-)
Kaj
29-Mar-2011
[648]
Red turns out to be classic: