World: r4wp
[#Red] Red language group
older newer | first last |
Kaj 25-Jun-2013 [8709x5] | Yes, if you have that installed, just do |
fossil update | |
Added write-file-binary for good measure | |
Oops, I'm not returning the binary file length. Have to fix that oversight | |
Added a parameter to make read-file-binary return the file size | |
Bo 25-Jun-2013 [8714] | OK. |
Kaj 25-Jun-2013 [8715x2] | I updated the 6502 emulator to use it, so you can see an example there |
Luis, the Red Java bridge will be able to call generic Java code, so it should be possible to use the App Inventor library | |
PeterWood 26-Jun-2013 [8717] | Looking at the current bridge.red, It seems that the return value of a called a method of a Java object is treated as an integer by the bridge. Am I correct in thinking that is fine for integers and references to Java Objects? I presume logic! will be okay too (if caste back ) . I guess that the bridge doesn't support string or float values yet. |
DocKimbel 26-Jun-2013 [8718x2] | It does in the new bridge version I'm about to push online. |
I just need to make some addition to the Red/System compiler before. | |
PeterWood 26-Jun-2013 [8720] | That's great news. |
Bo 26-Jun-2013 [8721x5] | Are there any tutorials on how to write programs using Red? (Not Red/System - I know where the documentation is for that.) |
What I mean is something like Rebol in 10 steps, but maybe Red in 10 steps (assuming you already know Rebol). | |
For instance, I try to compile and run the following simple script: Red [] img1: load %img1.jpg print img1 | |
When I run it, I get the following error: *** Error: word has no value! unset | |
I know that Doc says Red isn't ready for general use yet, but I was wondering if maybe there were some resources so I could get started getting up to speed on it. When I started learning Rebol, it was probably even less complete. | |
Kaj 26-Jun-2013 [8726] | Yeah, Larry Wall bashed it for that |
Ladislav 26-Jun-2013 [8727] | Larry Wall used quite unrelated (and mostly invalid) arguments |
Kaj 26-Jun-2013 [8728x5] | No tutorials, though, but there's a fair amount of example code. It currently relies on being able to use a lot of REBOL knowledge |
The best thing is to program as basic as possible, and always be on the watch for missing stuff. For example, LOAD only works on strings, and there's no type checking, so it probably used the string value of %img1.jpg | |
With my I/O bindings you can READ a file and then LOAD it, but only UTF-8 text | |
Now that Red/System can read binary files, I could make a facility in Red, but it would have to do without a binary! type. I could return a handle to low level memory as an integer! | |
However, there would currently be no facilities to access the content at the Red level, so you would have to pass it to Red/System functions to do anything with it | |
Arnold 26-Jun-2013 [8733x2] | REBOL is almost completely made from C! Sometimes hard to follow where and how things come together. So happy Red comes to the Redscue. |
Can a function be overloaded in Red? Example do-this: function [input [integer! c-string!]][either type? input [do-one][do-other] ] | |
Kaj 26-Jun-2013 [8735x4] | That's not overloading, that's just a conditional |
Real overloading is possible in the compiler, but there's currently a bug in the interpreter that always makes it use the first function definition. This is fixed, but not yet in the master branch | |
do-this: :do-one | |
do-this: :do-other | |
Arnold 26-Jun-2013 [8739x2] | I ask this obviously because I want to replicate the REBOL behaviour of the random function that takes different arguments like random "abcdef" shuffeling the string; random 1.0 giving a random real between 0 and 1; random 6 giving an integer from 1 up and to 6. So in a sense I need a return type that differs too. REBOL (R3) solves this as far as I understand it by returning the pointer to the value (and somehow the type of the variable).I ask this obviously because I want to replicate the REBOL behaviour of the random function that takes different arguments like random "abcdef" shuffeling the string; random 1.0 giving a random real between 0 and 1; random 6 giving an integer from 1 up and to 6. So in a sense I need a return type that differs too. REBOL (R3) solves this as far as I understand it by returning the pointer to the value (and somehow the type of the variable). |
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] |
older newer | first last |