World: r3wp
[Red] Red language group
older newer | first last |
BrianH 20-Apr-2011 [1221] | Cool. That will allow us to reuse some of the the reasoning about code that has been made about those situations in other languages, and tweak the model to learn from their lessons. |
Dockimbel 20-Apr-2011 [1222] | Precisely. :-) |
BrianH 20-Apr-2011 [1223x2] | I was thinking about struct parameters to functions. If C doesn't allow struct parameters and return values, only struct references or pointers, then Red should follow that model when declaring functions with the cdecl calling convention, and similar restrictions for stdcall, fastcall, etc. Then when we need to support other calling conventions that do support passing actual structs as parameters, we can just add to the list (pascal or Delphi, for instance). |
I haven't had a chance to look yet... Does the revised struct model support seeing pointers as equivalent to references to structs with one member? | |
Dockimbel 20-Apr-2011 [1225x4] | Implicitly, yes. |
Calling convention: adding new ones shouldn't require much work (unless they are very exotic). | |
BTW, I was thinking these last days that I maybe should allocate a week before starting the work on Red's compiler, to implement an experimental JVM bytecode emitter (and a .class file format). The reason for that is to have a 2nd emitter (in addition to IA32) that is addressing a very different architecture. This should help make a cleaner abstraction layer for upcoming emitters (especially those not written by me). | |
I might alternatively pick up CLR for that task, thought (less work for the file format as it is basically PE). | |
BrianH 20-Apr-2011 [1229] | A good calling convention to add would be JNI, for Java and Dalvik code. We would have to reverse-engineer the behavior of the C macros and types that implement this in the JDK and NDK. |
Dockimbel 20-Apr-2011 [1230x2] | This should help make a cleaner abstraction layer To be more accurate, I think the current one is OK, but it will certainly need some tweaking when a 2nd emitter will be added, so better tweak it sooner than later. |
Brian: what about JNA? Isn't that interface better than JNI? | |
BrianH 20-Apr-2011 [1232] | Never heard of JNA. Java and Dalvik both use JNI. |
Dockimbel 20-Apr-2011 [1233] | http://en.wikipedia.org/wiki/Java_Native_Access |
BrianH 20-Apr-2011 [1234] | Sounds interesting. Is it an addon that can be used on a standard JVM? I'll look it over later, especially to see if Dalvik supports it. |
Kaj 20-Apr-2011 [1235x3] | I tested the new section headers on Syllable Desktop. We're a step further, but it doesn't work yet. It doesn't complain about them missing anymore, but about read-only and write sections overlapping, which our loader doesn't support, if I remember correctly |
This is from the kernel log: | |
0:bash::bash : memmap_instance() RO overlap RW (08048000 + 00001000 -> 08048000) 0:bash::bash : ERROR : execve(./hello) failed. Too late to recover, will exit | |
Dockimbel 21-Apr-2011 [1238] | Kaj: thanks for the report. I thought we were cleanly separating RO and RW sections in two different LOAD segments...maybe the flags are not correctly set in sections (or in section headers). I'll give it a look this weekend if Andreas has not the time to fix it before. |
Kaj 21-Apr-2011 [1239x5] | It's quite possible that the format is correct, but that the Syllable loader doesn't support it. It does work on Linux (although that may not use the section headers at all) |
I remember that we had a similar problem many years ago when the standard GNU software that we incorporate started generating such a construct in new versions of the toolchain. I think our solution was a quick hack, so on the one hand we can load a lot of current software, but on the other hand it is also fairly easy to upset our loader | |
It is also possible that other adaptations need to be made to the format. Syllable can load Linux binary dynamic libraries if the dependencies are not Linux specific, but it can't load Linux binary program executables as far as I know - which we are trying now. There are subtle differences in their configurations, which we may need to adjust for | |
Maybe the most obvious difference: it looks like the Red output uses the common TEXT_START_ADDR=0x08048000 while Syllable uses TEXT_START_ADDR=0x80000000 | |
Syllable maps the kernel into the first half of the address range. Programs are supposed to go into the upper half, but a Linux executable probably tries to map itself into Syllable's kernel area | |
Dockimbel 21-Apr-2011 [1244] | Could you try changing the base address in ELF.r? It is a the top of the file: context [ defs: [ image [ base-address 134512640 ; #{08048000} ] |
Kaj 21-Apr-2011 [1245x3] | Thanks, I will |
-= Red/System Compiler =- Compiling /resources/Red/tests/hello.reds ... 660 ** Math Error: Math or number overflow ** Where: resolve-symbol-refs ** Near: pointer/value: data-ptr + spec/2 foreach >> | |
Using 2147483648 ; #{80000000} | |
Oldes 21-Apr-2011 [1248] | What about using R3? |
Kaj 21-Apr-2011 [1249x2] | For what? |
64 bits? | |
Oldes 21-Apr-2011 [1251] | yes |
Kaj 21-Apr-2011 [1252] | I'd be pleased with that, but structs do nothing in R3 |
Oldes 21-Apr-2011 [1253x2] | ah.. so that will be a problem I guess. |
The struct is used in RED only for the syntax or something else as well? It would be quite easy to create an extension maybe. | |
Kaj 21-Apr-2011 [1255] | Anyway, 32 bits targets still require 32 bits arithmetic |
Geomol 21-Apr-2011 [1256] | Continuing from !REBOL3: When defining a minimum set of natives for a REBOL like language, at one point you have to consider ADD vs. +. If you have the + operator, you can create ADD as a function. On the other hand, if you can create your own operators (which isn't possible in REBOL), you could make + from ADD. So which one is more basic? Are both justified? |
Kaj 21-Apr-2011 [1257x2] | Depends on whether the point of view is grammar or semantics |
In a functional language, infix operators are usually considered syntax sugar. On the other hand, in Red/System, + is elementary | |
Geomol 21-Apr-2011 [1259x4] | Ok, make sense. So the answer kinda depends on whether you consider the language strictly functional maybe? |
Another function is the math EXP function. It just raises the number e to some power (the argument). A language like C (and probably most others languages) has this function (in the math library though). Probably to make code faster, but it can easily be defined as a REBOL function, right? | |
There are some rounding problems though, so it maybe can't be made easily, but probably using a trick. | |
>> exp 1 == 2.71828182845905 >> myexp: func [v] [2.71828182845905 ** v] >> myexp 32 == 78962960182685.1 >> exp 32 == 78962960182680.6 So we might need more digits for e. | |
Maxim 21-Apr-2011 [1263] | you know, I was half joking when I suggested this group... :-) |
Geomol 21-Apr-2011 [1264] | :) well, it's a good group for this, as Doc would consider these things at some point. |
Maxim 21-Apr-2011 [1265] | I just woudn't want it to take over the topical discussions related to actual Red implementation and use. |
Geomol 21-Apr-2011 [1266x2] | >> myexp: func [v] [2.7182818284590451 ** v] >> myexp 32 == 78962960182680.6 >> exp 32 == 78962960182680.6 With 2 extra digits, it seems to work. |
With e defined, the hyperbolic cos, sin, tan, etc. are easy (REBOL doesn't have these), and maybe also normal cos, sin, tan!? At least for complex numbers, but not so sure about reals. Maybe a better mathematician can tell us that? Ladislav? | |
BrianH 21-Apr-2011 [1268] | John, in a real REBOL-like language + is implemented using ADD; all operators redirect to their associated functions. You could do a similar trick with a compiled REBOL-like language like Red. This brings up another question though: Will Red implement operators in a fixed-predefined-set way like R2, or in a user-defineable way like R3? I hope the latter, though the former would make sense for Red/System, at least in the pre-Red stage of its development. |
Geomol 21-Apr-2011 [1269x2] | Are complex numbers considered in Red? |
User-defined operators are really nice, I think. Being able to write things like: remove 42 from [1 2 3 42 177 280] where FROM is just a simple FIND. | |
older newer | first last |