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

World: r3wp

[Red] Red language group

Kaj
20-Jun-2011
[2198]
Compiling /users/administrator/Red/test.reds ...
*** Compiler Internal Error: Script Error : Invalid path value: 1
*** Where: comp-either 

*** Near:  [emitter/branch/over/adjust/on c-true negate offset expr/1]
Dockimbel
20-Jun-2011
[2199]
Weird error...
Kaj
20-Jun-2011
[2200]
Yeah
Dockimbel
20-Jun-2011
[2201x2]
Oh I see what's wrong, let me fix that
Fix pushed.
Kaj
20-Jun-2011
[2203]
Thanks! Good turnaround again :-)
Dockimbel
20-Jun-2011
[2204]
Took me some time, had to run all the tests suite several times, 
refactor the code and find a meaningful commit log message. ;-)
Kaj
20-Jun-2011
[2205x6]
:-)
Jocko, input-line works both on WINE and on Linux, so I have no reason 
to believe it wouldn't work on Windows. What is your code that doesn't 
work?
Oldes, same for print-integer and print-1. What is your code that 
doesn't work?
Next:
dummy: func [return: [integer!]] [0]
either as-logic dummy [
	no
][
	no
]
*** Compiler Internal Error: Script Error : first expected series 
argument of type: series pair event money date object port time tuple 
any-function library struct event
*** Where: opposite? 
*** Near:  [first select/skip opp-conditions cond 2]
Dockimbel
20-Jun-2011
[2211x2]
Having a quick look at this error.
Seems related to my previous fix.
Kaj
20-Jun-2011
[2213]
Yeah, was to be expected
PeterWood
20-Jun-2011
[2214]
Added two tests to reflect the two cases above to cast-test.reds. 
It now fails with a compliation error.
Dockimbel
20-Jun-2011
[2215]
Fix pushed.
Kaj
20-Jun-2011
[2216]
Thanks, both
Dockimbel
20-Jun-2011
[2217x3]
Peter, the compilation error in the new type casting tests was not 
the right one. Variable initialization cannot happen in EITHER blocks 
now since today's following commit: https://github.com/dockimbel/Red/commit/31b87b9565004574174ba3bf02b4dfaa2db665f2
That change was required to fix issue #84.
Kaj: you're welcome. But no more fixes until tomorrow, bed time here.
Kaj
20-Jun-2011
[2220]
OK then, I'll release you from your duties for the duration of eight 
(8) hours ;-)
PeterWood
20-Jun-2011
[2221]
Thanks for the pointing out the initaliasation changes and fixing 
the tests.
Gregg
21-Jun-2011
[2222]
Great to see continued activity and progress on Red.
jocko
21-Jun-2011
[2223x2]
Kaj, I tested this morning, input-line works under Windows
My mistake was that I did not allocate the input buffer by

in: allocate 255 but by in: "" , which is not really an allocation
on an other hand, I cannot simply include the C-library in my script 
by :

#include %C-library.reds


instead, I must extract the used functions. (here _input-line and 
input-line)


The error message at the compilation is not visible in the console, 
because a large amount of text is printed. Maybe a double declaration. 
Any idea ?
Dockimbel
21-Jun-2011
[2225x2]
Jocko, this might be caused by a duplicate definition of ALLOCATE 
and FREE, but Kaj removed them from the C-library in the last revision. 
I just downloaded last revision and tested, I can include it in my 
scripts without any issue.
Gregg: thanks for your kind support.
Oldes
21-Jun-2011
[2227x3]
print functions from Kaj's C-library has different precedence than 
ordinary print/prin when you call the red's exe from REBOL using 
CALL/console command.
Which means.. if I have code:

print-1 "int %d" 1
print "hello"

I get in REBOL console:
>> call/console %builds/test.exe
hello
int 1== 0
in CMD:
int 1hello
Dockimbel
21-Jun-2011
[2230x5]
Confirmed here too (on Windows). PRINT-1 is printing after every 
other PRINT calls in a script.
It seems that they are not using the same streams.
This article explains the issue in the second note: http://support.microsoft.com/kb/190351/en-us
So flushing the C I/O streams is the solution:
  
    print-1 "int %d" 1
    flush-file null
    print "hello"

works fine.
A long-term solution could be to disable buffering of C's stdout 
stream, using a call to setvbuf(). It requires passing a stream pointer, 
so I am not sure this is doable now.
Kaj
21-Jun-2011
[2235x7]
The issue is that PRINT and PRIN use syscalls directly, and thus 
don't go through the buffering that the C library does on all I/O
In particular, the standard I/O streams stdin and stdout are line 
buffered. Flushing them is often more forceful than necessary: the 
same effect is achieved by printing a newline
Also, when doing an input-line on Linux, stdout is flushed automatically, 
so you can print a question with a prompt directly behind it
On Windows, every print operation seems to be flushed automatically. 
I haven't seen it ordered incorrectly when intermixed with the Red 
syscalls functions
The differing behaviour is indeed very confusing, but I don't think 
the proper solution is to disable buffering. In my opinion, when 
Red uses the C library, PRINT and PRIN should also go through it
NULL can't be used any more as the return value for a function that 
normally returns a pointer:
Compiling /users/administrator/Red/Red-ZeroMQ-binding/examples/reply-server.reds 
...
*** Compilation Error: wrong return type in function: receive 
*** expected: [message!], found: [none] 

*** in file: %/users/administrator/Red/Red-ZeroMQ-binding/examples/reply-server.reds 
*** in function: receive
*** at:  []
Dockimbel
21-Jun-2011
[2242x2]
It is caused by NULL clashing with EITHER return type static analysis. 
I am giving NULL an any-pointer! pseudo-type to solve that.
I have pushed a new commit that should fix your issue.
Kaj
21-Jun-2011
[2244]
Works. Thanks again! The 0MQ binding compiles again after some time
Dockimbel
21-Jun-2011
[2245]
About using C functions for printing, is there one that don't interpret 
backslash-escaped characters?
Kaj
21-Jun-2011
[2246x2]
Probably if you use print-1 "%s" STRING, because the second is not 
the format string
Actually, I've already had print-1 "\n" ... print "\n" instead of 
newline. Aren't the escapes interpreted at compile time, only in 
literal strings?