World: r3wp
[Red] Red language group
older newer | first last |
Kaj 19-May-2011 [1410] | That would be just a little code, and it's obvious that you have to develop your programs to stay in sync with a language that's in alpha status |
BrianH 19-May-2011 [1411] | Yup. But it's also good to warn them of planned developments once they're definitely planned, and this one is pretty well established. |
Kaj 19-May-2011 [1412] | Exactly, so that's the reason to start using the handle! type now |
BrianH 19-May-2011 [1413] | No, that's a good reason to *add the handle! type to Red/System* now, as a preemptively reserved word. Not a reason to use the word handle! to refer to a completely different thing. |
Kaj 19-May-2011 [1414] | It still means that I start writing "handle!" in my code now |
BrianH 19-May-2011 [1415x2] | Perhaps it could be a name for a non-dereferenceable void pointer type, since that's the closest C equivalent. |
Basically, Red's handle! type would be the same as R3's handle! type. Opaque value that is pointer sized, but can't be used as a pointer without typecasting, and no arithmetic possible. No conversions to other datatypes either in typesafe code. | |
Kaj 19-May-2011 [1417] | That's in Red. Red/System is a different context |
BrianH 19-May-2011 [1418] | Yes, but Red/System's main purpose is to do things with Red data, so it needs to have access to Red's types, even if its own literal types are different. So Red/System needs to have a handle! type, even though Red/System code would need to typecast values of that type to something else in order to be able to do anything with them. |
Kaj 19-May-2011 [1419] | I don't see why it couldn't be the same type |
BrianH 19-May-2011 [1420] | Alias types are user-defined. The handle! type would be system-intrinsic. |
Kaj 19-May-2011 [1421] | Yes, a temporary difference in declaration, because as of now, there is no handle! type to declare |
BrianH 19-May-2011 [1422] | As long as the type is defined in the core runtime code, rather than in user code, there is no difference. |
Kaj 19-May-2011 [1423x2] | Exactly |
And since it isn't defined in the runtime now, I have to write it myself until that time | |
BrianH 19-May-2011 [1425] | The main thing is that it needs to be defined as *non-dereferenceable* and *no pointer arithmetic allowed*, so if Red/System's equivalent of the void pointer is so restricted, that will do. If dereferencing or pointer arithmetic is allowed on Red/System's void pointer type, that needs to be fixed asap. |
Kaj 19-May-2011 [1426x2] | Why? That would be the behaviour in Red. Red/System's task is to actually be able to do something with a pointer |
Unless you want to make Red a true capabllities language, but you are opposed to that concept | |
BrianH 19-May-2011 [1428x2] | In a strongly typed language, which even Red/System is, dereferencing a pointer means getting a value back that is of a known type; pointer arithmetic means adding in increments of the size of that type. A void pointer references nothing, and that nothing has no size. You must be required to typecast to another pointer type explicitly if you want to dereference the pointer, or to know how much to increment or decrement it. |
The difference between Red and Red/System is that such typecasts are possible in Red/System. | |
Kaj 19-May-2011 [1430] | If Red/System truely is to be strongly typed, there needs to be more than just pointer! [integer!]. The issue I'm currently having is exactly that there is no matching declaration for what I need |
BrianH 19-May-2011 [1431] | Right, there need to be pointers to other types. And support for more types, for that matter. |
Kaj 19-May-2011 [1432] | I'm not under a strong impression that this is planned. So currently, I need to treat Red/System as weakly typed |
BrianH 19-May-2011 [1433x2] | It is not currently planned *by Doc* to have Red/System be a complete language, since he only needs it to access a few system libraries and implement the Red runtime. He's said that others are welcome to contribute the necessary changes to make Red/System a more complete language. |
If you want to use Red/System as-is to do more advanced stuff than that, then go ahead and break the rules. Or better yet, add the features you're missing. | |
Kaj 19-May-2011 [1435x4] | I understand the burdens of future programs, but I've written a program right now that I have to keep working |
In other words, the rules you're talking about don't exist | |
Still, I would welcome Red/System becoming strictly strongly typed | |
If and when that happens, I'll update my programs to be compliant, as I'm doing now | |
BrianH 19-May-2011 [1439] | Well, it can't become strictly strongly typed, as a certain amount of type breakage is the whole point of its existence. You can't be strictly strongly typed if you have typecasting, pointer arithmetic, literal pointer values, or the ability to call C code. Red/System is supposed to be strongly typed with those rule breakers, in order to shield Red itself from those features. |
Kaj 19-May-2011 [1440x15] | Ehm, yes, that's what I've been saying all the time |
Doc, defining handle! with alias doesn't work: | |
*** Compilation Error: invalid struct syntax: [handle!] *** in: %/users/administrator/Red/Red-ZeroMQ-binding/examples/../ZeroMQ-binding.reds *** at: [struct [ content [handle!] | |
#define doesn't work, either: | |
** Script Error: Cannot use path on none! value ** Where: check-arguments-type ** Near: if all [ not empty? spec: entry/2/4 block? spec/1 ] [ spec: next spec ] foreach | |
You wanted to know if the appointed error locations are correct. That seems to be alright, and the error for a struct is nicely descriptive, but an error for a function definition is rather unspecific: | |
*** Compilation Error: invalid definition for function send: [ socket [pointer!] data [pointer!] size [integer!] flags [integer!] return: [logic!] ] *** in: %/users/administrator/Red/Red-ZeroMQ-binding/examples/../ZeroMQ-binding.reds *** at: [func [ socket [pointer!] | |
Oh wait. I have to use a block for #define, and then it works. But not ALIAS | |
And the error output for a function starts at the offending parameter, so that's actually pretty good, but it's not obvious | |
Here's a message that's not very clear: | |
*** Compilation Error: type mismatch *** expected: [pointer!] , found: [integer!] *** in: %/users/administrator/Red/Red-ZeroMQ-binding/examples/../ZeroMQ-binding.reds *** at: [0 as-message message data] | |
I can't compare pointers to zero any more. Presumably, these are the arguments to the zero? function, but that information is lost | |
As a nitpick, there's an excess space in the message, before the comma | |
It seems that NULL is defined as integer! 0 | |
So it seems that there is no way anymore to pass a null pointer to a function or to compare a pointer to null | |
Andreas 19-May-2011 [1455x2] | null-p: as [pointer! [integer!]] 0 |
does that work? | |
Kaj 19-May-2011 [1457x2] | I tried AS POINTER! |
The only syntax I can get to compile is as pointer! [integer!] 0 | |
Andreas 19-May-2011 [1459] | null-ptr: pointer [integer!] null-ptr/value: 0 should probably work as well |
older newer | first last |