Questions tagged [red-system]

Red/System is a domain-specific dialect of the Red language, which is used as the Intermediate Language for Red. A Red/System compiler is embedded into the Red executable, and generated code operates within striking distance of that output by most C compilers.

Red/System is a domain-specific dialect of the Red language--with similar capabilities to C, and some hardware-specific abilities. It uses the same syntax of REadable Notation ("REN") that and do, and follows the format of most of their basic constructs. But its datatypes are lower-level, and it is not homoiconic. Thus although Red can reflect and generate Red/System source as a data structure, Red/System cannot do this to its own code.

The dialect notably serves as the Intermediate Language (IL) for code generation in Red, and can target several ARM and x86 platforms; including Linux, Windows, OS/X, and Android. The Red runtime library is also written in Red/System. Performance of Red/System's generated code operates within striking distance of that output by most C compilers, though completely matching optimized C performance is considered unlikely by the project lead.

Any Red executable can generate code from Red/System input files (*.reds). Also, Red files (*.red) can embed Red/System code--similar to how C sources can embed inline assembly. It's relatively simple to make bindings to C libraries or DLLs, and several are available for projects like , , , and more.

15 questions
10
votes
1 answer

Is it possible to write a Windows DLL in Red?

I'd like to write a plugin for some Windows application, and it must be a DLL. I'd really love to try doing it in a mix of Red & Red/System. But asking on Rebol&Red chatroom here on SO, I got mixed responses as to whether it is currently possible in…
akavel
  • 4,789
  • 1
  • 35
  • 66
6
votes
1 answer

Pointers to an 'array' in Red/System

How do I make a pointer to the first element in an array in Red/System? Assigning an address to a pointer is no problem: my-integer: 1 ptr: declare pointer! [integer!] ptr: :my-integer The array is declared. buffer: as int-ptr! allocate 1009 *…
iArnold
  • 333
  • 2
  • 10
4
votes
1 answer

Pass by reference in Red routines

So I'm currently in the process of migrating a descent sized program from Rebol 3 to Red. Said program relies on a large binding to a C library (clang). I have rewritten the binding portion in Red/System, and am interfacing that code with Red…
iceflow19
  • 752
  • 4
  • 12
4
votes
2 answers

Accessing runtime functions from Red/System

So the issue came up while experimenting with marshaling values back and forth between Red and Red/System. I would like to access the guts of an object passed to a routine. I had noticed that there are functions in the Red Runtime for handling…
iceflow19
  • 752
  • 4
  • 12
3
votes
2 answers

How to create a Red/System binding to a function that takes a pointer to a pointer?

I was looking at how Red/System hooks up with C library functions from Windows DLLs, Linux/Android .so shared libraries, and OS/X .dylib, with the #import syntax: #import [ "libc.so.6" cdecl [ allocate: "malloc" [ size…
2
votes
1 answer

How to append data to block from R/S?

I am trying to append data to block from Red/System. Red [] my-red-block: ["some text"] ; some already existen data in block foo: routine [ blk ] [ block/rs-append as red-block! blk as red-value! unicode/load-utf8 "new text" size? "new…
Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145
2
votes
1 answer

How to pass value from Red/System to Red?

I need to pass the value that I generate in Red/System to Red. I discovered docs but did not find an example of how to use it. Here is my code: Red [] #system [ data!: alias struct! [ a [integer!] b [c-string!] ] …
Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145
2
votes
2 answers

Pass Red function pointer to C

I know how to pass a Red/System callback to a C function, but is the same functionality possible to achieve with Red? It is possible to create a Red/System wrapper for a Red function at runtime and pass it to a C function? I've already looked at a…
nickkoro
  • 374
  • 3
  • 15
2
votes
1 answer

invalid target type casting: red-context

I am using the --red-only switch with the verbosity set to 2 to compile a very simple Red program to its Red/System equivalent. The program is: Red [] red-load: func [source [file! url! string! binary!]] [ load source ] It produces a certain…
1
vote
1 answer

How to cast between integer and character in Red/System?

If I try writing this: foo: "whatever" bar: 0 if foo/1 <> as char! bar [ ;-- stuff ] Then I am told: Compilation Error: invalid target type casting: char! But if I omit the as char and write: foo: "whatever" bar: 0 if foo/1 <> as char! bar…
1
vote
2 answers

How do you use #call directive for Red function with string datatypes as parameters?

Given a script, such as below, which does not compile yet, how can I use #call to use my Red function from within Red/System? Red [] pff: function [a [string!] ][print a] #system [ #call [pff "hello"] ] There is a type mismatch. What…
kealist
  • 1,669
  • 12
  • 26
1
vote
1 answer

How do you get a directory listing in Red/System?

I've tried to include Kaj de Vos's excellent C library binding available in ANSI.reds, but still cannot find a way to read a directory listing. I thought that maybe if I could read the . file in binary, I could parse it, but I just get back a NULL…
Respectech
  • 454
  • 4
  • 13
0
votes
1 answer

How to pass block with context to routine?

I am continue to learn Red/System. And now I am trying to understand how to pass word with context to function. Here is my code: Red [Note: "compile in release mode (-r flag)"] mycontext: context [ list: [] ] foo: routine [ blk /local…
Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145
0
votes
1 answer

How to represent a hex string in Red/System?

How would one represent a literal string of binary data in hex in Red/System? It's not possible to do this: blah:…
kealist
  • 1,669
  • 12
  • 26
0
votes
2 answers

Red/System binding for 3D graphics on Raspberry Pi

For someone getting started with Red/System programming on the Raspberry Pi, what is the best way to access the GPU for 3D rendering? Can this method also be used for Rebol3 on the Raspberry Pi?
Respectech
  • 454
  • 4
  • 13