C++ Exception compatibility idea

A

Asfand Yar Qazi

Hi,

I have a dream... no, it doesn't involve little black kids and
little white kids, it involves Ruby (or some other scripting
language) and C++.

I'd love it if a language supported a feature whereby a C++
exception thrown in a C++ function is automatically processed and
caught in an enclosing Ruby raise/rescue block, and a Ruby
exception is caught and processed in a C++ try/catch block.

Obviously, I could create wrappers that do this at every language
boundary (which is easy) but it would be cool if this was built
into the interpreter, so it could be done without having to go
through any hassle.

I read on the Ruby wiki that it is being considered that Rite be
written (or Riten lol) in C++... could this be a neat little feature?

Thanks,
Asfand Yar
 
H

Hal Fulton

Asfand said:
I'd love it if a language supported a feature whereby a C++ exception
thrown in a C++ function is automatically processed and caught in an
enclosing Ruby raise/rescue block, and a Ruby exception is caught and
processed in a C++ try/catch block.

Obviously, I could create wrappers that do this at every language
boundary (which is easy) but it would be cool if this was built into the
interpreter, so it could be done without having to go through any hassle.

I read on the Ruby wiki that it is being considered that Rite be written
(or Riten lol) in C++... could this be a neat little feature?

I think this *might* be accomplished with some kind of add-on wrapper
lib for C extensions. My knowledge is limited there, so don't take me
too seriously.

As for implementing Rite in C++, I seem to remember Matz saying he would
*not* do such a thing. Where on the wiki did you see the comment?


Hal
 
P

Phil Tomson

Asfand Yar Qazi wrote:


As for implementing Rite in C++, I seem to remember Matz saying he would
*not* do such a thing. Where on the wiki did you see the comment?

I've been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit easier
because Objective-C and Ruby have some things in common philosophically.
Also you could take advantage of Obj-C's collection classes where needed.
Since Objective-C is just an add-on to C it probably wouldn't be too hard
to build on existing code. Also, Objective C is supported by GCC.

....of course, the downside on Windows is that the Microsoft compilers
don't support Objective C so all builds would have to be done under Cygwin
or MinGW. That may be a problem for some. There wouldn't be any problems
on the Mac OSX platform, though ;-)

Phil
 
M

Matthias Georgi

I've been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit
easier
because Objective-C and Ruby have some things in common philosophically.
Also you could take advantage of Obj-C's collection classes where needed.
Since Objective-C is just an add-on to C it probably wouldn't be too hard
to build on existing code. Also, Objective C is supported by GCC.

But you have to ship also the Objective-C runtime lib, so you have either
the dependancy or it will blow up the interpreter in static builds.

Recently, I was looking into ocaml and was impressed by the type inference
system, proving that c++ templating is the wrong way, also the
pattern matching is a nice concept.
And concerning speed, ocamlc is unbeatable.

Just for fun I looked at the great language shootout page
and there is a nice score matrix.
I typed in for CPU 1, Memory 2 and Lines of Code 3 as factors and voila,
ocaml at the first two ranks and ruby at rank 5.

Finally it depends on matz's language skills, impementing the
interpeter is hard enough and I think, a reasonable fast implementation
is possible in all of the common languages (non interpreted).
 
S

Stephen Steiner

I'm trying to install Ruby's readline module on OS X and am having the
following problem:


When I run:

ruby extconf.rb

I get:

checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no

The question is, where are the paths that 'have_library()' is going to
search? It is finding the header files but can't seem to find the
library (libreadline.a).

Thanks!

Steve
 
S

Shu-yu Guo

The question is, where are the paths that 'have_library()' is going to
search? It is finding the header files but can't seem to find the
library (libreadline.a).

It looks like that it adds CONFIG['libdir'] to -L.

As a sidenote, perhaps it would be easier if you used a ports system to
compile your Unix stuff, like DawrinPorts. It saves me a good deal of
trouble.
 
S

Stephen Steiner

Unfortunately, I often need the most recent builds of things and they
are not usually supported by the DarwinPorts as far as I can tell.

For example, I wanted to replace the Apple supplied Ruby with 1.8.1 but
I wanted the 'stable-snapshot' instead of the release version. As far
as I know, that would not be available using DarwinPorts.

Steve

The question is, where are the paths that 'have_library()' is going
to search? It is finding the header files but can't seem to find the
library (libreadline.a).

It looks like that it adds CONFIG['libdir'] to -L.

As a sidenote, perhaps it would be easier if you used a ports system
to compile your Unix stuff, like DawrinPorts. It saves me a good deal
of trouble.
 
J

Jim Freeze

I've been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit easier
because Objective-C and Ruby have some things in common philosophically.
Also you could take advantage of Obj-C's collection classes where needed.
Since Objective-C is just an add-on to C it probably wouldn't be too hard
to build on existing code. Also, Objective C is supported by GCC.


Matz has also said that you shouldn't write an OO language in an OO
language.

--
Jim Freeze
The man who follows the crowd will usually get no further than the
crowd. The man who walks alone is likely to find himself in places no
one has ever been.
-- Alan Ashley-Pitt
 
M

Mark Hubbart

I'm trying to install Ruby's readline module on OS X and am having the
following problem:


When I run:

ruby extconf.rb

I get:

checking for tgetnum() in -lncurses... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes
checking for readline() in -lreadline... no

The question is, where are the paths that 'have_library()' is going to
search? It is finding the header files but can't seem to find the
library (libreadline.a).

Have you installed a copy of readline on your system? There are two
possibilities here:
1. make and install a readline library, or
2. if you were lucky enough to have a copy installed with your
developer tools, link it to your /usr/lib directory.

If a copy was installed, it should be under
"/System/Library/PrivateFrameworks/readline.framework/"; If it's not
there, you'll probably have to compile a copy.

Since it was installed on mine, I haven't had to compile it. But I hear
that other people's setups don't have it, so I don't know.

HTH,
--Mark
 
J

jm

Why not cut out the middle man and write a gcc compiler for ruby? Just
to throw a crazy idea around.

J.
ps. like the sig.
 
H

Hal Fulton

Michael said:

I think it had something to do with the mismatch between the languages.
Confusion between Ruby objects and C++ objects (which work differently)
and all that.

Easier to describe an OO language like Ruby procedurally. But IANYM.


Hal
 
A

Ara.T.Howard

I think it had something to do with the mismatch between the languages.
Confusion between Ruby objects and C++ objects (which work differently)
and all that.

Easier to describe an OO language like Ruby procedurally. But IANYM.


'IANYM'.gsub /.*/, ??


-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================
 
A

Ara.T.Howard

'IANYM'.gsub /.*/, ??

forgive the self reply - just got it - too funny.


-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| URL :: http://www.ngdc.noaa.gov/stp/
| TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
===============================================================================
 
J

James F. Hranicky

On Fri, 14 May 2004 08:23:51 +0900
I've been thinking lately that it might be easier to do a Ruby
implementation in Objective-C. Seems like it could make life a bit easier
because Objective-C and Ruby have some things in common philosophically.
Also you could take advantage of Obj-C's collection classes where needed.
Since Objective-C is just an add-on to C it probably wouldn't be too hard
to build on existing code. Also, Objective C is supported by GCC.

I brought this up a long time ago, but I don't know if I brought it up well.

I think it would be great if Ruby could be used as a frontend for the ObjC
runtime for GNUstep or OSX. Ruby Objects are just handles for ObjC objects.

Ideally, any extension written in ObjC would automatically be available in
Ruby.

Feasible? I have no idea, but if it is, it seems like you could get just about
all the features desired out of such a backend, since they're already there in
the ObjC runtime.

Jim
 
S

Sam Roberts

I brought this up a long time ago, but I don't know if I brought it up well.

I think it would be great if Ruby could be used as a frontend for the ObjC
runtime for GNUstep or OSX. Ruby Objects are just handles for ObjC objects.

Check out Ruby/cocoa, it sounds like what you want.

Sam
 
A

Aredridel

I brought this up a long time ago, but I don't know if I brought it up well.
I think it would be great if Ruby could be used as a frontend for the ObjC
runtime for GNUstep or OSX. Ruby Objects are just handles for ObjC objects.

Ideally, any extension written in ObjC would automatically be available in
Ruby.

Have you tried RIGS or ruby-cocoa?

Ari
 
J

James F. Hranicky

Have you tried RIGS or ruby-cocoa?

No, but those don't affect the way the backend runs, right? I'm thinking
that a pure ObjC backend would support native threads and be relatively fast,
things desired out of Rite.

I could be talking out of something other than my mouth, but I'd like to see
someone who knows what their talking about give an informed opinion :->

Jim
 
A

Aredridel

Have you tried RIGS or ruby-cocoa?
No, but those don't affect the way the backend runs, right? I'm thinking
that a pure ObjC backend would support native threads and be relatively fast,
things desired out of Rite.

Well, things written in ObjC appear as Ruby classes -- it becomes a
second backend of sorts.

Ruby code is still run by the C interpeter, but it can call ObjC
classes.
I could be talking out of something other than my mouth, but I'd like to see
someone who knows what their talking about give an informed opinion :->

Rite or another implementation -could- be written in ObjC, and I'd love
to see it happen. Portability to Windows is an issue, but I'm content
there.

There are some things in Ruby that don't map to ObjC, so a backend that
simply compiled Ruby to ObjC can't happen: things like eval would have
to invoke the compiler, and Ruby allows a few things (like adding member
variables to classes at any time) that ObjC doesn't.

Ari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,373
Latest member
Desiree036

Latest Threads

Top