Re: [zeromq-dev] Questions about Coding Style

2012-02-12 Thread Mikko Koppanen
On Sun, Feb 12, 2012 at 9:28 PM, Gary Wright at2002+...@me.com wrote: ruby client code = ruby binding = libzmq C binding = C++ core So I would just apply the principle described above to each interface. The C++ code should use error codes/exceptions according to C++ idioms. The libzmq C

Re: [zeromq-dev] Questions about Coding Style

2012-02-12 Thread Gary Wright
On Feb 12, 2012, at 4:40 PM, Mikko Koppanen wrote: On Sun, Feb 12, 2012 at 9:28 PM, Gary Wright at2002+...@me.com wrote: ruby client code = ruby binding = libzmq C binding = C++ core So I would just apply the principle described above to each interface. The C++ code should use error

Re: [zeromq-dev] Questions about Coding Style

2012-02-12 Thread john skaller
On 13/02/2012, at 8:28 AM, Gary Wright wrote: ruby client code = ruby binding = libzmq C binding = C++ core I actually think this is a problem. Basically, the C binding is just that: it's just another binding. What I mean is, there should probably be two interfaces: 1) Core interface, to be

Re: [zeromq-dev] Questions about Coding Style

2012-02-12 Thread john skaller
On 13/02/2012, at 9:24 AM, Gary Wright wrote: Perhaps the solution is to have two interfaces to the library. Heh! I just wrote that too. A 'paranoid' interface that reports errors as much as possible and a 'go wild' interface that simply assumes that everything has been checked. The

Re: [zeromq-dev] Questions about Coding Style

2012-02-12 Thread Chuck Remes
On Feb 12, 2012, at 5:01 PM, john skaller wrote: On 13/02/2012, at 9:24 AM, Gary Wright wrote: Perhaps the solution is to have two interfaces to the library. Heh! I just wrote that too. I think allowing bindings to go directly to the C++ core interface will be problematic for a lot of

Re: [zeromq-dev] Questions about Coding Style

2012-02-12 Thread john skaller
On 13/02/2012, at 12:29 PM, Chuck Remes wrote: I think allowing bindings to go directly to the C++ core interface will be problematic for a lot of languages. Many languages interface to libzmq via FFI which, as far as I know, doesn't support C++ in any way, shape or form. These languages

[zeromq-dev] Questions about Coding Style

2012-02-11 Thread niXman
Hello list. Continuing review of the libzmq code, I have found a few situations when the program will be crushed on segmentation fault. On the one hand, it is possible to refer to an error because of the user. But on the other hand, Coding Style says: Assertions say that the ØMQ developers do not

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 11/02/2012, at 8:27 PM, niXman wrote: Continuing review of the libzmq code, I have found a few situations when the program will be crushed on segmentation fault. It's impossible to avoid this in C. I consider that programs crash on segmentation fault is an inadmissible error of the

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread niXman
2012/2/11 john skaller skal...@users.sourceforge.net: On 11/02/2012, at 8:27 PM, niXman wrote: Continuing review of the libzmq code, I have found a few situations when the program will be crushed on segmentation fault. It's impossible to avoid this in C. I consider that programs crash on

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 11/02/2012, at 9:23 PM, niXman wrote: In the example above, it is enough to add check on null pointer ( if (optvallen_ !(optval_)) {} ). This gives to the user more information about the error, instead of the silent crash. Agreed. Regarding the check of pointers of sockets, everything

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread niXman
2012/2/11 john skaller skal...@users.sourceforge.net: On 11/02/2012, at 9:23 PM, niXman wrote: In the example above, it is enough to add check on null pointer ( if (optvallen_ !(optval_)) {} ). This gives to the user more information about the error, instead of the silent crash. Agreed.

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Ian Barber
On Sat, Feb 11, 2012 at 11:06 AM, niXman i.nix...@gmail.com wrote: Meanwhile, even my simple patch [1] isn't accepted. [1] https://github.com/zeromq/libzmq/pull/240 ... it's been a day. You need to consider resetting your expectations of open source communities. Ian

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 11/02/2012, at 10:06 PM, niXman wrote: Before writing something, I want to understand the attitude of the project Administrators to innovations, and their readiness to take measures for improving libzmq. It's fairly clear in the policy. Meanwhile, even my simple patch [1] isn't

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread niXman
2012/2/11 john skaller skal...@users.sourceforge.net: On 11/02/2012, at 10:06 PM, niXman wrote: Before writing something, I want to understand the attitude of the project Administrators to innovations, and their readiness to take measures for improving libzmq. It's fairly clear in the

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Chuck Remes
On Feb 11, 2012, at 5:06 AM, niXman wrote: Before writing something, I want to understand the attitude of the project Administrators to innovations, and their readiness to take measures for improving libzmq. Meanwhile, even my simple patch [1] isn't accepted. [1]

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread niXman
2012/2/11 Chuck Remes cremes.devl...@mac.com: On Feb 11, 2012, at 5:06 AM, niXman wrote: Before writing something, I want to understand the attitude of the project Administrators to innovations, and their readiness to take measures for improving libzmq. Meanwhile, even my simple patch [1]

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread John D. Mitchell
Good morning, On Feb 11, 2012, at 01:51 , john skaller wrote: On 11/02/2012, at 8:27 PM, niXman wrote: [...] Continuing review of the libzmq code, I have found a few situations when the program will be crushed on segmentation fault. It's impossible to avoid this in C. That's bollocks. I

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Chuck Remes
On Feb 11, 2012, at 10:53 AM, John D. Mitchell wrote: On Feb 11, 2012, at 01:51 , john skaller wrote: On 11/02/2012, at 8:27 PM, niXman wrote: [...] Continuing review of the libzmq code, I have found a few situations when the program will be crushed on segmentation fault. It's impossible

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Peter Alexander
On Sat, Feb 11, 2012 at 12:37 PM, Chuck Remes cremes.devl...@mac.com wrote: On Feb 11, 2012, at 10:53 AM, John D. Mitchell wrote: On Feb 11, 2012, at 01:51 , john skaller wrote: On 11/02/2012, at 8:27 PM, niXman wrote: [...] Continuing review of the libzmq code, I have found a few situations

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Pieter Hintjens
On Sat, Feb 11, 2012 at 6:27 PM, niXman i.nix...@gmail.com wrote: For example the call: rc = zmq_setsockopt (sub, ZMQ_SUBSCRIBE, 0, 4); will end on segmentation fault on line 56 of the sub.cpp file. According to the documentation, if an error occurs, the function should return -1. I can

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread niXman
I'm confused ... Do you all agree with that the arguments must be checked? And with the fact that in case of error of arguments is not necessary to use assert but set errno and return -1? 2012/2/11 Pieter Hintjens p...@imatix.com: On Sat, Feb 11, 2012 at 6:27 PM, niXman i.nix...@gmail.com

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 12/02/2012, at 3:53 AM, John D. Mitchell wrote: Good morning, On Feb 11, 2012, at 01:51 , john skaller wrote: On 11/02/2012, at 8:27 PM, niXman wrote: [...] Continuing review of the libzmq code, I have found a few situations when the program will be crushed on segmentation fault.

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 12/02/2012, at 4:37 AM, Chuck Remes wrote: I will aggressively merge patches that make 0mq a safer and more forgiving library. No you won't :) You want a robust check? I can give you 99.%. But you'll pay. You already griped about the tiny weeny cost of my thread safe sockets (two

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread niXman
The problem with dangling pointers can only be solved using its own allocator. Thus, any address (pointer), not found among the selected blocks - is considered hanging. This, in its turn will not only reduce the number of errors, but that is not unimportant - will increase system reliability and

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 12/02/2012, at 6:47 AM, niXman wrote: I'm confused ... Do you all agree with that the arguments must be checked? And with the fact that in case of error of arguments is not necessary to use assert but set errno and return -1? IMHO, if you do a check for a NULL pointer you should use

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 12/02/2012, at 7:21 AM, niXman wrote: The problem with dangling pointers can only be solved using its own allocator. Sort of. You don't need to actually write an allocator. It is enough to trace all constructed sockets. This won't stop memory corruption of a legitimately constructed live

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Chuck Remes
On Feb 11, 2012, at 1:47 PM, niXman wrote: I'm confused ... Do you all agree with that the arguments must be checked? And with the fact that in case of error of arguments is not necessary to use assert but set errno and return -1? I think this is reasonable. If the community doesn't like

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Chuck Remes
On Feb 11, 2012, at 2:14 PM, john skaller wrote: On 12/02/2012, at 4:37 AM, Chuck Remes wrote: I will aggressively merge patches that make 0mq a safer and more forgiving library. No you won't :) You want a robust check? I can give you 99.%. But you'll pay. John, why do you

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 12/02/2012, at 7:44 AM, Chuck Remes wrote: On Feb 11, 2012, at 2:14 PM, john skaller wrote: On 12/02/2012, at 4:37 AM, Chuck Remes wrote: I will aggressively merge patches that make 0mq a safer and more forgiving library. No you won't :) You want a robust check? I can give

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 12/02/2012, at 8:03 AM, niXman wrote: Sort of. You don't need to actually write an allocator. It is enough to trace all constructed sockets. And what to do with pointers to the data for zmq_recv (), for example? void *data = 0x3423e65; zmq_recv(sock, data, 32, 0); Of course, the

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Pieter Hintjens
On Sun, Feb 12, 2012 at 4:47 AM, niXman i.nix...@gmail.com wrote: Do you all agree with that the arguments must be checked? And with the fact that in case of error of arguments is not necessary to use assert but set errno and return -1? Up to a point. Some invalid arguments are best handled

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Chuck Remes
On Feb 11, 2012, at 3:15 PM, john skaller wrote: On 12/02/2012, at 7:44 AM, Chuck Remes wrote: John, why do you make this more complex than it needs to be? I'm making a point. There are alternate viewpoints, and compromises in between. Both viewpoints are valid, as are compromises in

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread Gary Wright
On Feb 11, 2012, at 4:53 PM, Pieter Hintjens wrote: So in my libraries, like CZMQ, I validate input arguments with asserts, systematically. And yet for some language bindings it would be more idiomatic to raise an exception, rather than just have the process terminate. If libzmq returned an

Re: [zeromq-dev] Questions about Coding Style

2012-02-11 Thread john skaller
On 12/02/2012, at 11:40 AM, Gary Wright wrote: On Feb 11, 2012, at 4:53 PM, Pieter Hintjens wrote: So in my libraries, like CZMQ, I validate input arguments with asserts, systematically. And yet for some language bindings it would be more idiomatic to raise an exception, rather than