World: r3wp
[World] For discussion of World language
older newer | first last |
Geomol 15-Dec-2011 [708x3] | Example of using struct! in routine definition: my-routine: make routine! [ library "routine" [ [struct!] pointer ] ] |
A real example under OS X: timeval: make struct! [[ slong sec sint32 usec ] none] timezone: make struct! [[ sint minuteswest sint dsttime ] none] gettimeofday: make routine! [ [typecheck] libc "gettimeofday" [ tp [struct!] pointer tzp [struct!] pointer ] sint ] w> gettimeofday timeval timezone == 0 w> timeval/sec == 1323951188 w> timeval/usec == 314011 w> timezone/minuteswest == -60 w> timezone/dsttime == 0 | |
In the above example, libc is defined as: libc: load/library %/usr/lib/libc.dylib | |
GiuseppeC 15-Dec-2011 [711] | Hi, I am interested into building an maintaining documentation for those programming languages based on REBOL. It would be nice to have a DOCBASE for them. What I search is: - Someone ABLE to SETUP the Linux and the Wiki Software - Someone which would share with me the cost of hosting. Do you like the idea ? Write me at [giuseppe-:-chillemi-:-eu] |
Geomol 15-Dec-2011 [712x2] | There seem to be a problem with routines returning a handle. A library like MagickWand (part of ImageMagick) works this way. I'm not able to test it with MagickWand, as I'm not able to load that library for different reasons, and I don't wanna use too much time on it. So I'm after another library, that has a routine, which returns a handle, so I can test. A library easily to get for OS X, Linux and Windows would be nice. Any suggestions? |
I was able to load MagickWand under Linux, and it seems to work with uint32 datatypes to hold the handle (a C pointer). But it doens't work so well when using the handle! datatype for that. It would be nice, if it worked, I guess. It's probably some type casting problem. | |
Maxim 15-Dec-2011 [714] | actually, any library which returns a string could use a handle! as a return value instead. the handle could be used to store the reference to the string as-is and give it to another routine which requires a string on input. |
Geomol 16-Dec-2011 [715] | Yes, I'll check that out. |
Geomol 18-Dec-2011 [716x2] | New release at https://github.com/Geomol/World |
- Added native function: TRY - Added set-path! notation to set values in structs (POKE) - Added support for: to string! handle - Added context: system/words - Added helper function: ROUTINE - Added mold support for routines (SOURCE) - Added debugging function: ?? - Bugfixes | |
PeterWood 18-Dec-2011 [718] | Fast work John! |
Geomol 18-Dec-2011 [719] | Yeah, I'm in a productive period. |
BrianH 18-Dec-2011 [720] | Does TRY have an /except option? |
Ladislav 18-Dec-2011 [721] | Geomol, what would happen if you evaluate something like try [return 1] |
Geomol 18-Dec-2011 [722x4] | World is free to use and can be found at https://github.com/Geomol/World Why don't you try those things out yourselves? I would like to comment, but I feel, you get most from it by trying it. |
For minimum install, just pick one of the world_* files and cortex.w | |
To get a binary, click it, then click raw. | |
Ladislav, if you did try and mean having that code inside a function, then there was a bug, which will be fixed in next release. | |
Oldes 19-Dec-2011 [726] | w> c: context [a: 1 print a print (a)] 1 ** Script error: a has no value ** Near: print (a) |
Geomol 19-Dec-2011 [727x2] | Good one, thanks! |
About bit operations, I looked at SHIFT. R2 got it at some point, but there is no ROTATE. Wouldn't that be useful too? I think about graphics operations and maybe other areas. | |
Maxim 19-Dec-2011 [729] | yes ROTATE is handy to have native when you need it. its the kind of function which will be much slower to build manually than having it native (or hand optimised by the language author ;-) |
sqlab 19-Dec-2011 [730] | copying from an opened, but not connected tcp port crashes world-lang, |
Geomol 19-Dec-2011 [731x2] | Don't do that! ;) |
I need to find a balance with World for how much should be tested for. I'm after good performance. | |
sqlab 19-Dec-2011 [733] | if you open and connect and the peer closes, this happens too |
Geomol 19-Dec-2011 [734] | ok, that's a good argument to do something about it. Thanks! |
Geomol 20-Dec-2011 [735x4] | New release at https://github.com/Geomol/World |
- Reimplemented bitset! as binary - Added native function: COMPLEMENT - Added native function: ROTATE - Added native function: SHIFT - Added << and >> operators to cortex.w - Added hex form for characters, ^(00) - ^(FF) - Added REFORM to rebol.w - Added DETAB to rebol.w - Added ENTAB to rebol.w - New test - Bugfixes | |
About copying from a port, I get a zero, if the port is closed, but just under OS X and Linux. Windows version seems to hang in that situation. Networking code is open source, and you're welcome to suggest changes. I consider using a lib for networking instead of coding it all by hand. | |
SHIFT and ROTATE can only operate on 64-bit integers for now. We have to see, if operating on binary! and maybe other datatypes is needed. | |
sqlab 20-Dec-2011 [739] | at the moment i am just in holiday and have only limited access and not the infrastructure i am used too. maybe when i am back, i will have a look at the code. |
Geomol 20-Dec-2011 [740] | Suggestion: Some routines return a pointer to a structure, like LOCALTIME (from LIBC). The structure is struct tm and consists of 11 fields. In World, we can define LOCALTIME to return a pointer to a handle!, but how should we get to all the data fields? I suggest, TO should be used to copy data from a handle to a structure, like: tm: struct [ sint sec sint min sint hour sint mday ... ] none h: localtime time ; time is some variable holding seconds to tm h ; This will copy the data (pointed to by h) to tm Comments? Concerns? |
PeterWood 20-Dec-2011 [741] | As I understand localtime is not thread safe, the thread safe version locatime_r requires the address of a tm structure as an argument. (Though it returns the pointer to that same structure if the call is succesful. In general, isn't it a better option for strucutures to be allocated in World rather than the called function? |
Geomol 20-Dec-2011 [742x2] | Yes, it's probably a better idea to use routines, where you can allocate the structure in World, and handle the routine a pointer to it. But some routines does the other thing. In the case of localtime, it's a static buffer. Some routines in some libraries dynamic allocate memory, that the user can deallocate again with other routines. (Oldes pointed me to such a case in ImageMagick.) If World should support calling such routines and be able to operate on the result, we need something like my suggestion, I think. |
In the ImageMagick/MagickWand example, it was a string, and it's possible to get the string from a handle in World with: to string! handle I thought of something similar with structs. | |
PeterWood 20-Dec-2011 [744] | The to approach seems neat syntactically but is there a danger it would be slow with large data structures? |
Geomol 20-Dec-2011 [745x4] | I don't think so, as it's a simple memcpy. The C code looks like this: if (rb->type == STRUCT_T) { if (rc->type == HANDLE_T) { Struct *U = (Struct *) rb->value.rc; memcpy (U->u, (char *) ((Handle *) rc->value.rc)->pointer, U->size); } else invalid_argument (W, rc); } else invalid_argument (W, rb); |
The alternative (as I see it) is to not be able to access such structures. | |
Routines able to operate on structures, you define in World and give a pointer to to the routine, doesn't need this memcpy, and it'll work today. | |
To avoid the memcpy, the AS function could be used to redefine a handle to a struct. Like: as tm handle , but then handle is redefined as a struct, and it now points to a mem area, the routine made. So this can't be deallocated by World, and the memory management has to deal with that situation. Not good in my view. | |
Geomol 22-Dec-2011 [749x4] | New release at https://github.com/Geomol/World |
- Added ability to run script from command line - Added command line options: -i -q -v - Added usage (view usage for example with: world -?) - Now cortex.w is found, even if world is started from other directory (using argv[0] in C) - Added facility to copy handle data to struct: to <struct> <handle> - Removed ?? (not useful because of binding rules) | |
I found a way under OS X using AppleScript to launch World scripts from the Finder by dobble-click, and to start World the same way, if anybody is interested. It may be useful for REBOL and other languages as well. The method makes a world.app. Speak up, if you need it. | |
I would like to hear your experiences with launching world scripts from command line, or use world to run services, etc. | |
Oldes 22-Dec-2011 [753x2] | world_win32 -? crashes on W7 64bit |
ech.. crashes completely when I run it from CMD... starting by clicking on icon is fine | |
Geomol 22-Dec-2011 [755x3] | I test under WinXP with cmd and with cygwin bash terminal, and it works: C:\world\src>.\world.exe -? Loading Cortex... Done usage: .\world.exe [options] [script] ... I should get a Win7 soon, then I can test that. |
And then I should be able to make 64-bit Windows version too. | |
You should also be able to see the usage with any other option not recognizes, like: world -h Maybe the -? is the problem? | |
older newer | first last |