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

World: r3wp

[Red] Red language group

Pekr
9-May-2011
[1378]
Doc - there is many such small platforms, even x86 based IIRC. Gumstix 
is e.g. for real, a bit pricey, but definitely not vapor - http://www.gumstix.com/store/catalog/product_info.php?products_id=256
Dockimbel
9-May-2011
[1379]
Right, but not at $25 (the one you posted is sold $229).
Pekr
9-May-2011
[1380x3]
Right, but is sold right now, without the "we plan to develop" attitude 
:-)
I personally bought Beagleboard. Pandora Board might be even better 
....
Small enough for us.
Kaj
9-May-2011
[1383]
I think we can have faith in David Braben
Kaj
10-May-2011
[1384x2]
I have updated the 0MQ binding to the latest Red version, and moved 
it to a Fossil repository:
http://rebol.esperconsultancy.nl/Red-ZeroMQ-binding
Dockimbel
10-May-2011
[1386x3]
Thanks, will test is tomorrow.
From sources: "libzmq.dll" cdecl [  ; stdcall for Windows? => should 
be cdecl, stdcall is used in Windows DLL (and rarely by C libs).
vsm-data1	[integer!]  ; unsigned char [ZMQ_MAX_VSM_SIZE] (default 
30)

 => we will need a better way to handle such arrays when interfacing 
 with third-party libs...
Kaj
10-May-2011
[1389x2]
Yes
I found the same info that Windows system libraries use stdcall, 
but that MSVC defaults to cdecl. I had been compiling the binding 
with stdcall, and both work. I standardised on cdecl and retained 
the comment for the moment being
Kaj
19-May-2011
[1391x3]
I'm getting this:
Compiling /users/administrator/Red/Red-ZeroMQ-binding/examples/reply-server.reds 
...
*** Compilation Error: invalid struct syntax: [pointer!]

*** in: %/users/administrator/Red/Red-ZeroMQ-binding/examples/../ZeroMQ-binding.reds
*** at:  [struct [
        content [pointer!]
        flags [byte!]
What's the new syntax for a pointer field in a struct?
Dockimbel
19-May-2011
[1394x2]
pointer! [integer!]
Actually it isn't a new syntax, it's just that the compiler wasn't 
checking it deep enough until now.
Kaj
19-May-2011
[1396x2]
Shouldn't an actual pointer! type be possible?
What you're saying, that's a pointer to an integer, right? But I 
need a pointer to a bigger memory area here
Dockimbel
19-May-2011
[1398x2]
Pointer! alone is equivalent to an integer, it just represent an 
address, but can't be dereferenced.
If you are just passing the pointer! reference but never dereferencing 
it, you could just use integer! instead (or c-string!).
Kaj
19-May-2011
[1400x2]
Yes, it's just to reserve the space for a pointer that's used by 
0MQ, but not by Red
I'm trying to use pointer! as much as possible instead of integer! 
because it makes clear that we're talking about an address size, 
not what happens to be the compiler's integer size
Dockimbel
19-May-2011
[1402x2]
Agreed. You could also use aliased types for that: 
    handle!: alias integer!
or
    void-ptr!: alias integer!


Aliased typed are not yet fully supported nor tested, but it should 
work fine in your case.
Sorry, I meant:
    handle!: alias pointer! [integer!]
or
    void-ptr!: alias pointer! [integer!]
BrianH
19-May-2011
[1404]
You might want to avoid using handle! for these, as it is the best 
candidate for the opaque-pointer-sized-value type in Red proper, 
that all of Red/System's pointer! types would appear to be when they 
leak into Red code.
Kaj
19-May-2011
[1405]
Well, isn't that exactly the reason to use it?
BrianH
19-May-2011
[1406]
I mean, don't use the word 'handle! as an alias because it will likely 
be a built-in datatype in Red, and in all Red/System functions and 
datatypes exported to Red.
Kaj
19-May-2011
[1407]
But it would be exactly what you want, wouldn't it?
BrianH
19-May-2011
[1408x2]
handle!: alias integer!

would override the built-in meaning of handle!. All code that uses 
that word would need to be changed when Red comes out.
Keep in mind that there is no bounds-checking for Red/System's pointer 
type, and Red/System has typecasting (rather than conversion). Neither 
of those would be allowed in Red itself because of typesafety issues. 
Red/System will be like the unsafe code of C#.
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