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

World: r4wp

[#Red] Red language group

Kaj
28-Jun-2013
[9006]
How are you calling your Red/System function from Red?
Arnold
28-Jun-2013
[9007]
exactly like I do as I would from the reds counterpart.
Kaj
28-Jun-2013
[9008]
That can't work. You can't call Red/System functions in Red
Arnold
28-Jun-2013
[9009]
??????
Kaj
28-Jun-2013
[9010]
Are you making calls from Red to Red/System, or are you only including 
a #system-global []?
Arnold
28-Jun-2013
[9011]
I shared all relevant files. In my view I include using the #system-global 
in randomf.red and I make the calls also via this intermediate red 
script calling random-taocp/ran_start from the random-taocp context 
in the %random-taocp.reds script
Kaj
28-Jun-2013
[9012]
Where are the latest ones?
Arnold
28-Jun-2013
[9013]
For convenience I kept all scripts in one folder, and rightly so, 
it is hard enough already.

Eh latest ones? in the Red/random (I deleted the randompublic folder 
because it was old and had old files in it anyway)
Kaj
28-Jun-2013
[9014x6]
Well, there you have it. In randomf.red you're using Red/System functions 
and contexts as if they're Red code. They're simply not defined in 
Red
To call Red/System code from Red, you have to write a ROUTINE to 
wrap the differences and marshall the arguments:
https://github.com/dockimbel/Red/commit/1426d1e70d4eaac19444d120f3bbdaa2fa2e438a
I'm getting this when running build.r on Linux Mint (based on Ubuntu):
Generating apk...
/bin/bash: builds/tools/aapt: Bestand of map bestaat niet
Signing apk...
jarsigner: unable to open jar file: builds/eval-unsigned.apk
Aligning apk...
/bin/bash: builds/tools/zipalign: Bestand of map bestaat niet
...all done!
Bestand of map bestaat niet
 means the file doesn't exist
Arnold
28-Jun-2013
[9020]
life w be so muchh easier ;-)
Kaj
28-Jun-2013
[9021]
It looks for aapt and zipalign in the wrong place, but they're not 
available, anyway
Bo
28-Jun-2013
[9022]
I'm diving into my first attempt at recursion in Red/System.
james_nak
28-Jun-2013
[9023]
Thanks Doc, that did it.
DocKimbel
28-Jun-2013
[9024]
Kaj: it worked fine on my Ubuntu system. Did the script download 
the binaries in builds/tools/ ? If not, can you please trace the 
reason why it didn't?
Kaj
28-Jun-2013
[9025]
I didn't see any download activity
DocKimbel
28-Jun-2013
[9026]
Try to delete the whole builds/ folder and try again.
Kaj
28-Jun-2013
[9027x2]
It worked now
I ran the script with R3 first, and it bombed out just before the 
downloading. It does very little error checking, so the folder structure 
was already created, and afterwards it skips the download completely
DocKimbel
28-Jun-2013
[9029]
Yes, you're supposed to use R2 for Red. ;-) The download is done 
once only, so it doesn't need extensive error checking, if something 
goes wrong, just delete the builds/ folder and run it again.
Kaj
28-Jun-2013
[9030]
Sure, but nobody knows that's what to do
DocKimbel
28-Jun-2013
[9031]
Now everbody knows. :-)
Kaj
28-Jun-2013
[9032]
Some people claim there's a world outside of AltME
PeterWood
28-Jun-2013
[9033]
They are wrong,  there is only the hell known as Stack Overflow.
Kaj
28-Jun-2013
[9034]
:-)
Arnold
28-Jun-2013
[9035]
:-)
Arnold
29-Jun-2013
[9036x3]
You can't call Red/System functions in Red

 that almost literally made me fall of the chair. Somehow I really 
 expected that to be inherently supported. I cannot make any chocolat 
 from the routine example atm, but as I see it now, it requires me 
 to reprogram/copy my Red/system program to Red and renaming FUNCTION 
 to ROUTINE. This means double maintenance in my eyes. 

This is definitely a point to add to the wishlist if you asked me.
Especially what good is the #system-global for then? Ah like #system 
in R/S documentation chapter 17
Also from this:

It will be possible to export some Red/System functions to be callable 
from the Red language layer. The method for such export hasn't been 
decided yet. Among possible options, it can be:

A special attribute 
in header that will list the functions to export
A function's attribute 
in the specification block
A compiler directive


I can taste that the integration is just around the corner. But which 
one? :)
Why should one want to 'hide' functions in a Red/System script you 
include? And why can one include a Red/System script in a Red script 
when you can't call the functions in it?
What is the most common use of this in practice later on?
Arie
29-Jun-2013
[9039]
Are there prefix equivalents for the infix operators (+ - etc.) ? 
When I enter + 3 6 in the console, it yields 6.  Why?
PeterWood
29-Jun-2013
[9040x5]
I can't authoriatively answer your first question (but I would guess 
the answer is no)


The interpeter  has returned 6 because it is the last value that 
it evaluated.
It would seem to be a bug that no error is raised when + has been 
used with its first argument missing.
The compiler also seems to have a bug:

The following code complies:

Red []

a: func [] [
	+ 3 6
]

print a
Its output is

3
Would you mind adding your finding to the bug tracker - https://github.com/dockimbel/Red/issues?state=open
Arie
29-Jun-2013
[9045]
done
DocKimbel
29-Jun-2013
[9046x5]
Just as a reminder: error handling is not implemented yet in Red, 
so no need to add ticket about not raised errors.
The few error reports you could encounter in Red are right now, just 
hardcoded, to be able to do minimal work with Red without wondering 
what's happening.
Arnold: it seems you didn't get that Red and Red/System are two different 
languages. As they are living in different abtraction layers, you 
can't expect to directly include code from one in the other. There 
are special interfaces for that purpose, ROUTINE is the main one 
for calling Red/System code from Red. That doesn't mean that all 
your Red/System code needs to be in a routine, just the interfacing 
code. The rest can be in different libraries that you load into Red/System 
space using #include in #system or #system-global directives. Including 
Red/System code into Red directly is not possible, because, these 
are two different languages. So you need to wrap your Red/System 
code (and Red/System includes) into a #system* directive.
Remember that Red compiles to Red/System code. The #system* directives 
are ways to inline Red/System code into Red.
...or more accurately: inline Red/System code into the output of 
Red program compilation.
Arnold
29-Jun-2013
[9051x3]
No in my view Red compiled to Red/System code and then to executable, 
so including the lower level Red/System in a Red program even by 
including other scripts would be evident.
And because I am compiling in this two-step rocket Red - Red/System 
and viewing Red/System as the low-level Red program ....
add 1 1
2
DocKimbel
29-Jun-2013
[9054]
What you describe is not #include directive, it's #system. Including 
Red/System code into Red (means mixing both Red/System and Red source 
codes) is simply not possible.
Maxim
29-Jun-2013
[9055]
coudn't it be done with the jit, if given a block to compile on demand? 
 (not saying its implemented, just thinking about how it could be 
done).   sort of like inlining ASM code in C.