World: r4wp
[#Red] Red language group
older newer | first last |
Arnold 26-Jun-2013 [8740] | That is twice the same sorry for that! AltMe hung up on me and I pasted overenthousiasticly. |
Kaj 26-Jun-2013 [8741x4] | You don't need overloading for that, just type conditionals. REBOL uses those all the time, and so can Red |
REBOL and Red don't have pointers. What you're talking about is a Red value the type of which is always known at runtime | |
So you can always check the type of a value, and you can return a value of any type | |
Some languages dispatch a function to multiple implementations depending on the types of its arguments, but that's multiple dispatch, not necessarily overloading | |
Arnold 26-Jun-2013 [8745] | Hey invalid Red program if I #include a reds program? Complaint about /System *** Syntax Error: Invalid Red program *** line: 1 *** at: {/System [^M |
Kaj 26-Jun-2013 [8746] | Red is not Red/System, is it? |
Arnold 26-Jun-2013 [8747] | Expected this to be no problem at all. Just not the other way around. I feel tutorial stuff coming up. |
Kaj 26-Jun-2013 [8748x2] | To write Red/System within Red, you need to enclose it in |
#system-global [ ] | |
Arnold 26-Jun-2013 [8750] | seen that before. Had no clue what it was for. |
Kaj 26-Jun-2013 [8751x2] | It's usually me who uses it, and it usually #includes Red/System files :-) |
I guess Red #include could be made to inspect the type of the file, and add an implicit #system-global [ ] if it's Red/System | |
Arnold 26-Jun-2013 [8753] | Thank you it compiled. Now I have to find out what this means *** Error: word has no value! *** Script error: action 42 not defined for type: 2 logout |
Kaj 26-Jun-2013 [8754] | That depends on what you're doing |
Arnold 26-Jun-2013 [8755x2] | That would be a nice improvement indeed as the file extension is reds and the header is Red/System |
Apparantly action 42 ;) sorry bedtime now for me. | |
james_nak 26-Jun-2013 [8757] | Hello2 working on Nexus 7 - Great job Doc. I have to hit the "DO" button twice to see a result but it works. |
Bo 26-Jun-2013 [8758] | I have this bit of Red/System code that I wrote, but for some reason, it just closes the console window. So I don't know if there is an error, and if there was, how would I debug it? #include %../C-library/ANSI.reds img1: as-binary 0 size1: 0 img2: as-binary 0 size2: 0 img1: read-file-binary "img1.bin" :size1 print-line img1 print-line size1 print-line as integer! img1/1 img2: read-file-binary "img2.bin" :size2 print-line img2 print-line size2 img3: as-binary size1 i: 0 until [ i: i + 1 img3/i: img2/i - img1/i i = size1 ] write-file-binary "img3.bin" img3 size1 until [no] |
Arnold 27-Jun-2013 [8759x4] | Generally speaking, I drastic approach is to comment everything out and gradually uncomment lines until you find the place where the problem gets introduced. |
And or adding lines where you print information to the console print [" before call to read-file-binary, size of size1: " size1 lf] | |
write-file-binary has a logic! return value write-ok: write-file-binary "img3.bin" img3 size1 | |
And even try to initialize img3 by img3: read-file-binary "img2.bin" :size2 that way img3 can be subscripted like img1 and img2, not sure now about your as-binary from integer what you have now. | |
PeterWood 27-Jun-2013 [8763x3] | I am not familiar with Kaj's Libraries but I searched ANSi.reds and the Red/System runtime to try to find where as-binary is defined. I guess it must be in one of Kaj's other libraries. I noticed the ANSI.reds includes %common/FPU-configuration.reds but couldn't find that in Kaj's Repo. (It doesn't sound as though it would include a definition of as-binary though). |
Though if as-binary is not defined, you would definitely get a compilation error. | |
Do you get any output from the print statements ? | |
Arnold 27-Jun-2013 [8766x2] | I created an account on the red.esperconsultancy site hoping it would bring a little more possibilities in browsing up the tree. This was not the case. I am sure that it must be there somewhere but you have to know or have a link or own the server ;) (@Peter, your last question is to Bo about his print-line statements I presume.) |
@action 42 I think I was not returning the return value and violating various other things at the same time | |
DocKimbel 27-Jun-2013 [8768] | Bo, it seems you're starting Red/System programs by clicking on them? If that's the case, it's not the best way to debug such programs. You need to open a DOS window and launch the programs from there. The window will never close, so you'll be able to see all the messages and avoid doing infinite loops at the end of your code. |
Arnold 27-Jun-2013 [8769x3] | Click <start> and type cmd.exe another hint is to have a textfile at hand with a suitable cd command. |
I stumbled upon a possible bug with local variables. flexfun-s: function [s [string!] return: [string!]][return s] flexfun-i: function [i [integer!] return: [integer!] ][return i] flexfun: function [n [integer! float! string!] return: [string! integer! logic!] /local rv uitstr uitint][ rv: type? n either "string" = rv [uitstr: flexfun-s n][uitint: flexfun-i n] ] When I do not declare the uitstr and uitint local variables, the compiler makes a ~local extra and notices double declaration: Compiling to native code... Script: "Red/System IA-32 code emitter" (none) *** Compilation Error: duplicate variable definition in function exec/f_flexfun *** in file: %/Users/Arnold/data/develop/red/testscripts/flextst1.red *** at line: 126 *** near: [func [/local ~n ~local ~rv ~local ~uitstr ~uitint] [ push ctx194/values | |
When I declare both everything is ok. | |
DocKimbel 27-Jun-2013 [8772x2] | Arnold, good catch, pleas add it to the bugtracker. |
@james_nak, thanks for testing. Your issue is probably related to the fact that the output area in this demo has a fixed height, so it probably is a bit out of screen on your device, that's why you can't see the first output value. | |
Pekr 27-Jun-2013 [8774] | ha, demo pushed :-) |
DocKimbel 27-Jun-2013 [8775x4] | Yes, but you'll need to put all the pieces together in a single folder to be able to build it with Eclipse...I'm working on automating the APK building process, if I can't finish on time, I'll just provide a link with an archive of the eval demo project suitable for Eclipse, so you can at least have a chance to mess things around in the meantime. ;-) |
Well, actually, I've just packaged it so here's the link: static.red-lang.org/eval-droid.zip | |
You just need to unzip it in a dedicated folder, install ADT (Android Development Tools) which contains both the SDK and Eclipse, install a JDK, open the project in Eclipse and compile it. For the Red part, there's a precompiled eval.red version in libs/armeabi/libRed.so. You can recompile it with the following command-line options: "-t Android -dlib". Ensure that you replace it with exactly the same name at the same place, then recompile the whole project. | |
If the automation script I'm working on work, you'll be able to generate an APK without download the SDK and JDK! ;-) | |
Pekr 27-Jun-2013 [8779] | I don't want to use Eclipse, nor any other SDK :-( Willing to use command-line tools as javac etc. Btw - I use Android Studio, so actually wonder, if I would be able to do it using it instead of Eclipse ... |
DocKimbel 27-Jun-2013 [8780x2] | Just wait an hour more to see if I can finish the automatic building toolchain... |
Believe me, Eclipse is actually much easier to compile/build/test an android app than manually calling the command-line tools. | |
Pekr 27-Jun-2013 [8782x2] | I know, it is just that I am multiplexing between work, red, creating ads for my led screen, photo shooting, photo editing, video editing. So basically I just jump here or there, and right after I was suggested to use Android Studio last month, because - it comes from Google, I am now supposed to install yet another toolchain. Last month I also installed my Visual Studio 2013 and got really scared by the complexity of all that stuff, that comes with it .... |
So - I can wait, but maybe not, I am fast at trying new stuff and making my Window8 installation even more messy with constantly trying new SWs :-) | |
DocKimbel 27-Jun-2013 [8784] | Hmm, can't avoid Java dependency...maybe I should be able to use the preinstalled JRE on Windows platforms, but not sure... |
Pekr 27-Jun-2013 [8785] | Nevermind, in any case, some description of how to proceed, is going to be needed. But it is a pity, as it pushes us to the different land, where no more the claim of sel-contained dev environment is true. Now we are in a lend of - do regular Android JAVA development and use Red DLL, when handy ... |
Arnold 27-Jun-2013 [8786] | issue #492 added on https://github.com/dockimbel/Red/issues?state=open |
DocKimbel 27-Jun-2013 [8787x2] | Ok build script pushed. You need to have JDK (correctly) installed currently for the script to work. |
The jarsigner tool needs to access the Java runtime...we'll remove that dependency partially or fully in the future. | |
Pekr 27-Jun-2013 [8789] | Holly crap! That works! |
older newer | first last |