Right, you might need method names containing “!” and “?” characters or
operator method names like “===” etc. The constants are also easier to
setup in a library that’s using the initializers. The initializers are
no magic though. The generated initializer for a given library is
invoked by load_assembly method in file.rb that you require to load the
library. For example, enumerator.rb:
load_assembly ‘IronRuby.Libraries’,
‘IronRuby.StandardLibrary.Enumerator’
RubyMethod/RubyClass/RubyConstant/… attributes declare what the
generated initializers should do. They are not used at runtime. You can
write your custom code that builds Ruby classes and registers them to
the runtime using APIs on RubyModule/RubyContext. You could then invoke
the code from your_lib.rb file that you require to load your library.
Tomas
From: [email protected]
[mailto:[email protected]] On Behalf Of Shri B.
Sent: Sunday, October 11, 2009 12:44 PM
To: [email protected]
Subject: Re: [Ironruby-core] IronRuby C# Extensions
Tomas, assuming you wanted your library to be C# code only for whatever
reason, wouldn’t you need to use RubyModuleAttribute etc for various
reasons (other than performance) to make the library look really
Ruby-friendly and also be multi-ScriptRuntime-aware? For example, if you
wanted a class constant, you couldn’t just declare a C# “const” variable
as that would be appdomain-wide and also read-only. So you have to tag
it with “RubyContantAttribute”, right?
From: [email protected]
[mailto:[email protected]] On Behalf Of Tomas M.
Sent: Sunday, October 11, 2009 11:48 AM
To: [email protected]
Subject: Re: [Ironruby-core] IronRuby C# Extensions
Ideally Reflection would be fast and we wouldn’t need any workarounds to
load built-ins fast. But that’s not the case, so we use initializers.
As for the scenarios you mentioned:
-
Porting Ruby native extensions
Why not to write them in Ruby with calls to .NET Framework assemblies?
Is there anything that makes this difficult?
-
Create an IronRuby library in C# in order to improve performance of a
certain operation
Couldn’t you write the parts whose perf matter in C# code that doesn’t
have all the Ruby bells and whistles and keep your library written in
Ruby?
Tomas
From: [email protected]
[mailto:[email protected]] On Behalf Of Shay F.
Sent: Sunday, October 11, 2009 10:26 AM
To: [email protected]
Subject: Re: [Ironruby-core] IronRuby C# Extensions
By the way, if we’re at the subject… Ivan does have a point there, but
why were the standard libraries written this way?
Thanks,
Shay.
On Sun, Oct 11, 2009 at 7:19 PM, Shay F.
<[email protected]mailto:[email protected]> wrote:
Right, but this way you have more control on the “translation” of your
Dll to IronRuby.
Shay.
On Sun, Oct 11, 2009 at 7:14 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:
But wouldn’t you be able to accomplish these scenarios just by requiring
a C# built dll?
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
On Sun, Oct 11, 2009 at 7:03 PM, Shay F.
<[email protected]mailto:[email protected]> wrote:
2 samples I can think of -
- Porting Ruby native extensions
- Create an IronRuby library in C# in order to improve performance of a
certain operation
Shay.
On Sun, Oct 11, 2009 at 6:57 PM, Ivan Porto C.
<[email protected]mailto:[email protected]> wrote:
Just require an assembly should work just as well I guess.
When would you need to use the RubyClass etc attributes and the
initializer? What is the added value of those?
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto C.
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)
On Sun, Oct 11, 2009 at 6:51 PM, Shay F.
<[email protected]mailto:[email protected]> wrote:
Is it possible to consider allowing to load extensions without the need
of a library initializer? (another argument in the load_assembly method
for example)
Currently, the library initializer makes the whole thing much more
complicated…
Thanks,
Shay.
On Sun, Oct 11, 2009 at 6:27 PM, Tomas M.
<[email protected]mailto:[email protected]>
wrote:
Basically to avoid reflection when loading the classes and modules.
Tomas