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

World: r3wp

[Red] Red language group

Dockimbel
14-Jun-2011
[1997x3]
I am currently working on runtime error catching. I have successfully 
redirected default handlers for SIGILL, SIGSEGV, SIGFPE on Linux, 
but on Windows, the systems seems to ignore my handlers (using signal( 
) function). So I am currently testing with SetUnhandledExceptionFilter() 
(http://msdn.microsoft.com/en-us/library/ms680634%28VS.85%29.aspx)
If anyone has experience with that API on Windows, advices and tips 
are welcome. :-)
Steeve: I failed to install that version too, but here are special 
install images for Vmware and VirtualBox under "Emulate Syllable" 
bar here: http://web.syllable.org/pages/get-Syllable.html#installation-CD
Steeve
14-Jun-2011
[2000]
Thanks, I'll try it
Dockimbel
14-Jun-2011
[2001]
My Syllable image on Vmware works well (as long as I keep the mouse 
in the VM during the boot sequence, else it fails to be detected).
Steeve
14-Jun-2011
[2002]
Btw, How do you use a Vmware image instead of an iso one. I don't 
see any option to do so with VirtualBox
Dockimbel
14-Jun-2011
[2003x2]
You just do from menu: File->Open.
(on Vmware)
Steeve
14-Jun-2011
[2005]
Hmm...
Gregg
14-Jun-2011
[2006]
Great to see continued progress on Red!
Dockimbel
14-Jun-2011
[2007]
Thanks Gregg, we are currently reaching the first milestone of the 
project with a fully capable Red/System language, just a few more 
implementation fixes, the specification draft to complete, and I 
will declare it beta (means "usable" for real work).
Kaj
14-Jun-2011
[2008x5]
Cool news :-)
Steeve, did you use the VirtualBox boot entry?
hello-syllable.bin confirmed working on the Syllable Desktop development 
build. Thanks to Andreas
The INTERP section can be removed from the binary because it is not 
applicable to Syllable
This removes the last barrier for me to start using Red for real 
work :-)
Mchean
16-Jun-2011
[2013]
Is Red is just Linux at the moment?
nve
16-Jun-2011
[2014x4]
No Win32
also Win32
And MacOSX
The aim is to be cross platform including ARM support
Mchean
16-Jun-2011
[2018x2]
and does it have a console?
like the rebol console?
Kaj
16-Jun-2011
[2020x2]
Windows, Linux and Syllable, no Mac
No console, but you can just use the system's console
Mchean
16-Jun-2011
[2022]
well this is very cool!
Kaj
16-Jun-2011
[2023x2]
BSD definitions are currently being entered into Red, so maybe the 
platforms list is already out of date :-)
It should be quite easy to get it to run on the BSD systems from 
the current state
jocko
17-Jun-2011
[2025]
I tried to write a console input function (no one is available up 
to now AFAK).
This one works (for windows):
#import [
	"kernel32.dll" stdcall [
		ReadConsole: "ReadConsoleA" [
		  	handle		[integer!]
		  	buffer		[c-string!]
		  	len			[integer!]
		  	read		[struct! [value [integer!]]]
		  	reserved	[integer!]
		  	return:	[integer!]
		]
	]

]

stdin: GetStdHandle WIN_STD_INPUT_HANDLE
__read: struct [value [integer!]]
	

input: func [s [c-string!] return: [c-string!] /local in][
		;in: "" ; don't work
		in: allocate 255  ; must be freed after !
		prin s
		ReadConsole stdin in 255 __read 0
		a: __read/value - 1; because of the line return symbol \n
		in/a: #"^(00)" ; necessary to add it !
		in
	]

; usage :
res: input "enter a string : "
print res

my questions : 
- is this correct ?
- how and where de-allocate the c-string ?
- why the end-string symbol is not added automatically ?
Kaj
17-Jun-2011
[2026x3]
My C library binding has a range of input functions
I don't know if your code is correct, because it's Windows specific. 
It's quite possible that the Windows functions don't close strings 
with the trailing zero. My impression is that Windows wasn't originally 
built on the C standard library
The memory you allocate in your input function is returned from the 
function, so it must be freed outside the function, after every call
jocko
17-Jun-2011
[2029x2]
Have you tried the input functions of your C library binding ? I 
tried input-line (under windows) some time ago, and it did not work. 
At that time, i did not try to allocate the c-string
Under windows, the problems with input-line (which uses gets) are 
probably the same as those that I faced in my implementation : to 
allocate the c-string buffer, to terminate the string properly.
Andreas
17-Jun-2011
[2031x3]
man gets:
BUGS
       Never use gets().
:)
jocko
17-Jun-2011
[2034]
I agree, should use fgets
Kaj
17-Jun-2011
[2035x5]
Since this is open source, I was thinking to let the community do 
the testing. Thanks for the report :-)
I was afraid the gets type functions are implemented as macros, so 
that may well be the problem. The thing is that I can't fix it by 
using the fgets type functions, because Red can't import the standard 
file descriptors such as stdin yet
We talked that over with Nenad and it's planned
input-next may have the same problem, but did you try it?
Strings are terminated properly with gets/input-line but you must 
allocate an unknown storage size, which is warned for in the source 
of the binding
Kaj
18-Jun-2011
[2040x3]
The binaries Red generates with a binding are now ten times as big 
as a few weeks ago, because it now generates code for #import definitions. 
Is that correct?
When I have a struct! as a local variable, is only the pointer to 
the struct reserved on the stack, not the struct itself?
When I make a STRUCT for a local variable within a function, is it 
created on the heap, so that I need to free it?
Dockimbel
18-Jun-2011
[2043x4]
Bigger binaries: yes, it is caused by #import bindings and by runtime 
message strings.
Local struct variable: that is correct, only the pointer is stored 
in the stack frame.
STRUCT is used to declare literal structures. As all literals, it 
is stored in the data segment of the executable image, you don't 
need to free it as it is not allocated with a malloc() call.
Kaj: have you found the "struct [...]" construction somehow misleading?


I am asking this because there is a discussion about that on the 
mailing-list and I need to decide this weekend if I keep pointer/struct 
literal declarations as-is or change it.