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

World: r3wp

[Red] Red language group

Dockimbel
23-Jun-2011
[2473]
(as return type)
Kaj
23-Jun-2011
[2474]
No, we discussed that
Dockimbel
23-Jun-2011
[2475]
I don't remember the conclusion?
Kaj
23-Jun-2011
[2476]
Only possible when the #import returns 0 and 1 exactly
Dockimbel
23-Jun-2011
[2477]
Ah right!
Kaj
23-Jun-2011
[2478]
Anyway, returning 0 for succes is unnatural for humans, but very 
natural for C. If there is no REBOL like way to process the reverse 
logic! return, the C way becomes more attractive, and the code shifts 
towards C instead of REBOL
Dockimbel
23-Jun-2011
[2479]
I still don't get why you can't solve that with wrapper functions?
Kaj
23-Jun-2011
[2480]
How do you mean? Writing three extra functions just for that one 
ALL expression?
Dockimbel
23-Jun-2011
[2481]
I mean writing wrappers for low-level ZMQ imported functions, so 
that they return consistent values. For example, RECEIVE should return 
a message! or null, but not a 0 that needs to be casted to logic!.
Kaj
23-Jun-2011
[2482]
I did. NULL also needs to be cast to logic
Dockimbel
23-Jun-2011
[2483]
Also, those wrappers could handle the low-level ZMQ errors, so that 
the user don't have to do it.
Kaj
23-Jun-2011
[2484]
No, because there is no standard for error reporting, like in REBOL. 
You have to do error trapping the C way
Dockimbel
23-Jun-2011
[2485]
I just mean findind a way to catch those 0 values transparently.
Kaj
23-Jun-2011
[2486x2]
There is no 0, only NULL, and this is my attempt at implementing 
the error catching, transparent or not
I know you don't want more changes before implementing Red, and that's 
fair enough, but this is something we'll need eventually
Dockimbel
23-Jun-2011
[2488]
Here a code example of how you could solve that:
	msg: receive ....
  	if zmq-error? [...process error...]


zmq-error? could just check a flag set by last zmq low-level calls.
Kaj
23-Jun-2011
[2489]
Such constructs would make the binding a lot more high level and 
would require a lot more code. I'm trying to keep complexity down 
for simplicity and performance
Dockimbel
23-Jun-2011
[2490x2]
calls => call
The added code won't make any significant overhead in performances 
for a network communication library, the slow parts are the network 
exchanges.
Kaj
23-Jun-2011
[2492x2]
What bothers me most is the added complexity that doesn't really 
solve the problem. Error handling is often something that needs to 
be done locally, because that's where the knowledge is to handle 
the problem most gracefully
We don't have goto and longjumps, either, so there's little leeway 
for implementing a transparent error trapping framework
Dockimbel
23-Jun-2011
[2494x2]
Btw, your code snippet could be rewritten as:

message: receive socket 0
unless all [
	as-logic message
	end-message message
	;wait 1
	send socket  as [byte-ptr!] reply  1 + length? text  0
][

 prin "Received request: "  print as-c-string message-data message
	print zmq-form-error system-error
]
Huh, I guess I have been too aggressive with the prin "..." line 
:)
Kaj
23-Jun-2011
[2496]
If you want the function to return a logic! status and a result to 
be able to handle it locally, the result needs to fetched through 
a pointer, which also raises complexity. We can't handle addresses 
very well yet, either, because get-words only work for native functions
Dockimbel
23-Jun-2011
[2497x2]
My point was: don't return a logic! statut from functions like RECEIVE, 
rather set a flag and check it after RECEIVE call.
statut => status
Kaj
23-Jun-2011
[2499x2]
RECEIVE doesn't return logic?
That rewrite doesn't work. It mixes up successful and unsuccessful 
receiving
Dockimbel
23-Jun-2011
[2501]
Yeah right, I was confused by your will to return a logic!.
Kaj
23-Jun-2011
[2502x5]
I'm flexible. :-) Not everything returns logic, only the cases that 
can
I'll just rewrite it in EITHERs for now. I'm just noting that it 
can be made very nicely REBOL like to distinguish Red/System from 
C
By the way, 0MQ is not a network communication library per se. It 
can do messaging equally well between processes and even threads, 
so wrapper performance is significant
x: does []
either true [x] [x]
*** Compiler Internal Error: Script Error : equal-types? expected 
type1 argument of type: word
*** Where: comp-either 
*** Near:  [last-type: either equal-types? t-true t-false]
Dockimbel
23-Jun-2011
[2507]
Regression from a recent change, you should get a compilation error 
saying that x is missing a return value.
Kaj
23-Jun-2011
[2508x2]
In this case, I don't need EITHER to return a value
The crash is on the EITHER not on the DOES
Dockimbel
23-Jun-2011
[2510x2]
Ok, so sounds like a check that shouldn't happen in such case.
Could you post this error (and future others) to github's tracker 
please? It is easier for me to manage them there.
Kaj
23-Jun-2011
[2512]
I won't like loosing the comfort of AltME, but I'll try
Dockimbel
23-Jun-2011
[2513]
Thanks.
Kaj
23-Jun-2011
[2514]
I've put it in there, but I won't be able to follow the discussion 
much
Dockimbel
23-Jun-2011
[2515x2]
It is more a matter of tracking than discussing.
It is also easier for others to follow current issues publicly.
Kaj
23-Jun-2011
[2517]
I understand; it's just a rotten situation that the communication 
isn't integrated
Dockimbel
23-Jun-2011
[2518]
We have #red-lang on Freenode for that. ;-)
Kaj
23-Jun-2011
[2519]
I don't do IRC, either. It's not integrated, just more fragmentation
PeterWood
23-Jun-2011
[2520]
What is AltME integrated with?
Kaj
23-Jun-2011
[2521x2]
The REBOL community?
Boron is using all the right open source buzz words, except AltME, 
and look what traction it got