r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Red] Red language group

Kaj
18-Jun-2011
[2058]
No, I simplified the example. I actually wanted to get sizes of structs 
without allocating one
Dockimbel
18-Jun-2011
[2059]
Try with an alias (untested).
Kaj
18-Jun-2011
[2060]
Doesn't it get the size of the pointer then?
Dockimbel
18-Jun-2011
[2061x4]
Let me try...
SIZE? doesn't seem to recognize the alias.
An alias is an abstract definition, it doesn't allocated anything. 
So we can decide that the size of an alias is the whole struct size.
allocated => allocate
Kaj
18-Jun-2011
[2065x7]
Yes, that's what I would like
In the runtime, there's now a new generic pointer type defined:
#define byte-ptr!	c-string!
However, it's type incompatible with the previous definition, which 
NULL still uses:
null: 		pointer [integer!]				;-- null pointer declaration
The documentation specifies a third definition, namely integer!
This comes back to the lack of a void pointer type again
Dockimbel
18-Jun-2011
[2072]
There is a ticket about null: https://github.com/dockimbel/Red/issues/96
Kaj
18-Jun-2011
[2073x2]
Failing that, I think these definitions should use the same type
The new ALLOCATE and FREE use c-string! which makes using them on 
generic byte arrays, and comparisons with NULL, confusing
Dockimbel
18-Jun-2011
[2075]
NULL will be adapted to cop with that (either using polymorphism 
or by replacing it by a NULL? macro).
Kaj
18-Jun-2011
[2076x2]
I find ALLOCATE and FREE using c-string! unintuitive
Other types need to be cast to use these functions
Dockimbel
18-Jun-2011
[2078]
Same as malloc() with C void pointers.
Kaj
18-Jun-2011
[2079]
Still, why do we have now have three different definitions of a generic 
pointer?
Dockimbel
18-Jun-2011
[2080]
There is no such thing as a generic pointer in Red/System.
Kaj
18-Jun-2011
[2081]
I know, but I #define it as handle! like we talked about before, 
but there's now no way to define handle! in such a way that it works 
everywhere
Dockimbel
18-Jun-2011
[2082]
Have you tried with defining it as integer!?
Kaj
18-Jun-2011
[2083]
I once did, but I doubt it will now compensate for c-string! and 
NULL
Dockimbel
18-Jun-2011
[2084]
Integer! is conceptually the closest type to handle!.
Kaj
18-Jun-2011
[2085]
Yes, so why not define NULL and byte-ptr! as integer?
Dockimbel
18-Jun-2011
[2086]
About NULL, please read the ticket on github I have posted above. 
NULL will be changed.
Kaj
18-Jun-2011
[2087x2]
Sure, but why not fix this inconvenience right now?
I don't care what handle! is, just that there are three incompatible 
definitions
Dockimbel
18-Jun-2011
[2089]
Because I currently work on another ticket.
Kaj
18-Jun-2011
[2090x2]
It's just changing the two lines I cited above
I don't mean right now right now, I mean before making NULL polymorphic
Dockimbel
18-Jun-2011
[2092]
The NULL changes will be done this weekend, you won't have to wait 
too long.
Kaj
18-Jun-2011
[2093]
That still leaves the incompatibility between byte-ptr! and the documentation
Dockimbel
18-Jun-2011
[2094]
byte-ptr! as integer?: certainly not, byte-ptr! as it names implies 
is a byte! pointer, so semantically different than just integer!.
Kaj
18-Jun-2011
[2095]
But you're saying all the time that a void pointer is conceptually 
closest to an integer?
Dockimbel
18-Jun-2011
[2096x2]
Right.
You should erase the "void pointer" expression from your mind, it 
is corrupting your vision. :-)
Kaj
18-Jun-2011
[2098x2]
Again, I don't care much what it is (although I wouldn't expect ALLOCATE 
to return a c-string!), just that the definitions are compatible, 
so you don't have to insert confusing typecasts everywhere
I'm just following what you have written in the manual about pointers
Dockimbel
18-Jun-2011
[2100]
the definitions are compatible
: which ones?
Kaj
18-Jun-2011
[2101]
NULL, byte-ptr! and the manual use three type incompatible definitions. 
I must compare and pass these types
Dockimbel
18-Jun-2011
[2102]
NULL and documentation will be fixed during this weekend.
Kaj
18-Jun-2011
[2103]
So will they be compatible with byte-ptr! thereafter?
Dockimbel
18-Jun-2011
[2104x2]
NULL should work with any kind of pointer/struct or be removed.
I haven't decided yet on the right solution, but you can safely use 
ALLOCATE as it is defined right now, that won't be changed.
Kaj
18-Jun-2011
[2106]
Not really, because casts are needed on every use of ALLOCATE and 
FREE
Dockimbel
18-Jun-2011
[2107]
That would be the case whatever type you would put in the return 
definition of ALLOCATE?