World: r4wp
[#Red] Red language group
older newer | first last |
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. |
Kaj 29-Jun-2013 [9056] | You'd wrap ASM in C with an ASM marker, wouldn't you? |
Maxim 29-Jun-2013 [9057] | yes, in the compilers which support it. |
Kaj 29-Jun-2013 [9058] | Same thing. You need to wrap Red/System code inlined in Red with a Red/System marker |
Maxim 29-Jun-2013 [9059] | ok, so isn't that what Arnold is asking, basically? |
Kaj 29-Jun-2013 [9060] | No, he wants Red to read his mind. That's a common request among people :-) |
Maxim 29-Jun-2013 [9061] | I think its a common request in all languages ;-) |
Kaj 29-Jun-2013 [9062] | One could think of some constructs to integrate Red/System and Red even more closely than through a ROUTINE, but it's questionable whether it would be worth it |
DocKimbel 29-Jun-2013 [9063] | Android APK build script now works fine on OSX too. |
Bo 29-Jun-2013 [9064x3] | Finished my first crack at recursion in Red/System. Works great! Uncovered a bug (not in recursion, but in pointer indexing), but found a way to work around it for now. |
My Red/System script (through some technical wizardry) can now process 10 seconds of video from an HD source at 30fps and isolate motion areas of a particular size in a fraction of a second on a 700MHz Raspberry Pi. | |
:-) | |
PeterWood 29-Jun-2013 [9067] | Impressive !!! |
Bo 29-Jun-2013 [9068x2] | Thanks! |
My bug mentioned above may not actually be a bug, but a misunderstanding by me in how to pull values from pointers. It's listed at https://github.com/dockimbel/Red/issues/496 | |
PeterWood 29-Jun-2013 [9070] | In Red/System: p: declare int-ptr! ;; pointer i: 1 ;; integer p: :i ;; set p to address of i print as integer! p ;; prints the address of p ;; the cast (as integer!) is to allow print to treat the value as ;; an intteger print p/value ;; prints the value of i ;; no cast needed as i is already an integer! print p/1 ;; equivalent to print p/value Hope this helps. |
Bo 29-Jun-2013 [9071] | I should have that as a quick reference card on my wall. :-) |
Kaj 29-Jun-2013 [9072] | Congrats, Bo |
Maxim 29-Jun-2013 [9073x3] | kaj, can you help me get R3 sources compiling? |
or anyone else... in fact. | |
oh... sorry... wrong group! what heresy! | |
Arnold 30-Jun-2013 [9076x4] | Well done Bo! Yes those pointers and memory retrieving can be tricky, you can actually retrieve values from outside your boundaries, negative or too big, no problem. |
In the meantime, appreciating all thee help really, I cannot still make choclats from the routine and #system* examples given. Kaj's from friday and Docs example from 11 may and explanation from Sat 5:11/13. I now understand that the way I did things the process includes my Red/System source into my Red code and than compiling starts on the whole thing leading to the error I get. What my intention is, is not done, namely leaving Red/System code to be Red/System code and place this within the Red/System code generated from the Red compilation. What I think I also understand is that in order for the Red compilation to know a function is not found in the Red source because it is not know at that time, because it is defined in the Red/System source there should be some action as to make it known. That the blancs will be filled in at a later stage. | |
So first I include a reds source in my Red program. #system-global [#include random-taocp.reds ;-- and now this? #export [random-taocp/ran_start random-taocp/ran_arr_next] ;-- + all my functions needed ] ;-- and close the block of system-global In this Red/System code i use a context and functions within that context. I want to use a function from the Red/System code so I make a ROUTINE in my red source and from this routine I call my Red/System function get-random: routine [n [integer!] return: [integer!]][ random-taocp/ran_arr_next ] ;-- don't need the input here strictly speeking Is this in the right direction now? Thanks. | |
Not so easy. I'll have to resort to building a really simple example and try making that work. | |
older newer | first last |