Switch numexpr to C++

48 views
Skip to first unread message

Mark

unread,
Jan 22, 2012, 5:24:34 PM1/22/12
to numexpr
Numexpr only has two C files, interpreter.c and interp_body.c. I'd
like to switch them to compile with C++, and have already tried it
with minimal changes required. The differences were nearly all due to C
++ having stricter type conversion rules than C, something which I
think is very good. Is there anyone here attached to using C over C++?

-Mark

Francesc Alted

unread,
Jan 23, 2012, 2:39:21 AM1/23/12
to num...@googlegroups.com
2012/1/22 Mark <mww...@gmail.com>

Would the resulting code be able to compile with a plain C compiler?  And, can you tell what advantages would result in doing that?  Just curious.

--
Francesc Alted

Mark Wiebe

unread,
Jan 23, 2012, 3:04:06 AM1/23/12
to num...@googlegroups.com
Initially, yes. This change converts it into the subset shared between C and C++. Do you see an advantage to keeping it compileable in C over the long term? The days of poor C++ compiler support are long behind us now.

The ability to use objects and other C++ features to reorganize the code would be extremely helpful in my opinion, so I would prefer not to stick to the C subset. The contributions I've already made to numexpr were much more unpleasant to do than if it had been good quality C++ code. The performance is the same, any performance in C is also possible in C++.

Cheers,
-Mark
 
--
Francesc Alted

--
You received this message because you are subscribed to the Google Groups "numexpr" group.
To post to this group, send email to num...@googlegroups.com.
To unsubscribe from this group, send email to numexpr+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/numexpr?hl=en.

Francesc Alted

unread,
Jan 23, 2012, 3:15:34 AM1/23/12
to num...@googlegroups.com
2012/1/23 Mark Wiebe <mww...@gmail.com>
On Mon, Jan 23, 2012 at 1:39 AM, Francesc Alted <fal...@gmail.com> wrote:
2012/1/22 Mark <mww...@gmail.com>
Numexpr only has two C files, interpreter.c and interp_body.c. I'd
like to switch them to compile with C++, and have already tried it
with minimal changes required. The differences were nearly all due to C
++ having stricter type conversion rules than C, something which I
think is very good. Is there anyone here attached to using C over C++?

Would the resulting code be able to compile with a plain C compiler?  And, can you tell what advantages would result in doing that?  Just curious. 

Initially, yes. This change converts it into the subset shared between C and C++. Do you see an advantage to keeping it compileable in C over the long term? The days of poor C++ compiler support are long behind us now.

Yup, I think you are right: C++ compilers are ubiquitous now, and its advantages could be very important in many fields.
 
The ability to use objects and other C++ features to reorganize the code would be extremely helpful in my opinion, so I would prefer not to stick to the C subset. The contributions I've already made to numexpr were much more unpleasant to do than if it had been good quality C++ code. The performance is the same, any performance in C is also possible in C++.

Ok.  Seems good to me.  So +1 for C++ adoption.

--
Francesc Alted

Mark Wiebe

unread,
Jan 23, 2012, 4:46:12 PM1/23/12
to num...@googlegroups.com
I've pushed the changes, tested it on both Linux and Windows.

Francesc Alted

unread,
Jan 25, 2012, 2:49:07 AM1/25/12
to num...@googlegroups.com
2012/1/23 Mark Wiebe <mww...@gmail.com>
On Mon, Jan 23, 2012 at 12:15 AM, Francesc Alted <fal...@gmail.com> wrote:
2012/1/23 Mark Wiebe <mww...@gmail.com>
On Mon, Jan 23, 2012 at 1:39 AM, Francesc Alted <fal...@gmail.com> wrote:
2012/1/22 Mark <mww...@gmail.com>
Numexpr only has two C files, interpreter.c and interp_body.c. I'd
like to switch them to compile with C++, and have already tried it
with minimal changes required. The differences were nearly all due to C
++ having stricter type conversion rules than C, something which I
think is very good. Is there anyone here attached to using C over C++?

Would the resulting code be able to compile with a plain C compiler?  And, can you tell what advantages would result in doing that?  Just curious. 

Initially, yes. This change converts it into the subset shared between C and C++. Do you see an advantage to keeping it compileable in C over the long term? The days of poor C++ compiler support are long behind us now.

Yup, I think you are right: C++ compilers are ubiquitous now, and its advantages could be very important in many fields.
 
The ability to use objects and other C++ features to reorganize the code would be extremely helpful in my opinion, so I would prefer not to stick to the C subset. The contributions I've already made to numexpr were much more unpleasant to do than if it had been good quality C++ code. The performance is the same, any performance in C is also possible in C++.

Ok.  Seems good to me.  So +1 for C++ adoption.

I've pushed the changes, tested it on both Linux and Windows.

Looks good.  Thanks!

--
Francesc Alted
Reply all
Reply to author
Forward
0 new messages