Thibaut Barrère
2009-Mar-03 20:46 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Hi, while writing specs for Magic, I noticed that: instance_from(MenuItem, "Hello").text.*to_s*.should == "Hello" to_s is required to get the assertion to pass. The following will return false: button = Button.new button.text = "Hello" puts button.text == "Hello" So I guess that CLR strings cannot be compared to Ruby strings unless to_s is applied. While not a big deal, it''s a bit surprising. Is it something that is likely to change ? cheers, -- Thibaut -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090303/1da62b2f/attachment.html>
Meinrad Recheis
2009-Mar-03 22:11 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
On Tue, Mar 3, 2009 at 9:46 PM, Thibaut Barr?re <thibaut.barrere at gmail.com>wrote:> Hi, > > while writing specs for Magic, I noticed that: > > instance_from(MenuItem, "Hello").text.*to_s*.should == "Hello" > > to_s is required to get the assertion to pass. The following will return > false: > > button = Button.new > button.text = "Hello" > puts button.text == "Hello" > > So I guess that CLR strings cannot be compared to Ruby strings unless to_s > is applied. >I have stumbled on this too and was very surprised. This problem does not exist in IronPython (does it? please correct me if I am wrong). The behavior I was expecting is that "on the ruby" side all strings are (or at least behave exactly like) ruby strings, even if they come from .NET and are automatically converted to clr-strings when passed into clr methods. cheers, -- henon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090303/5adf94f1/attachment.html>
Meinrad Recheis
2009-Mar-03 22:19 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
On Tue, Mar 3, 2009 at 11:11 PM, Meinrad Recheis <meinrad.recheis at gmail.com>wrote:> On Tue, Mar 3, 2009 at 9:46 PM, Thibaut Barr?re <thibaut.barrere at gmail.com > > wrote: > >> Hi, >> >> while writing specs for Magic, I noticed that: >> >> instance_from(MenuItem, "Hello").text.*to_s*.should == "Hello" >> >> to_s is required to get the assertion to pass. The following will return >> false: >> >> button = Button.new >> button.text = "Hello" >> puts button.text == "Hello" >> >> So I guess that CLR strings cannot be compared to Ruby strings unless to_s >> is applied. >> > > I have stumbled on this too and was very surprised. This problem does not > exist in IronPython (does it? please correct me if I am wrong). The behavior > I was expecting is that "on the ruby" side all strings are (or at least > behave exactly like) ruby strings, even if they come from .NET and are > automatically converted to clr-strings when passed into clr methods. >In addition to that, it would also be great to have automatic type conversion on the .NET side too. I''d expect to be able to assign a string pulled out from the interpreter to a C# string without the need to call ToString(). For example, string s = engine.Execute("''hi''") as string; Currently s would be null because the dynamic cast to System.String fails. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090303/7a00c06c/attachment-0001.html>
Curt Hagenlocher
2009-Mar-03 22:41 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
This mismatch doesn''t exist in Python because Python''s string semantics are largely compatible with .NET''s string semantics. As a result, Python can actually use .NET''s strings as Python strings. Ruby strings, unfortunately, are mutable, which means that IronRuby has to use a different type to store a mutable string. In many cases, the binder should automatically perform the conversion between a CLR string and a mutable string. There are probably places (like this one) where something just hasn''t been implemented yet. And there may be places where we simply can''t do an automatic conversion. The mutable string type in Ruby is (in my opinion) one of the most unfortunate design decisions made in the language. From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis Sent: Tuesday, March 03, 2009 2:19 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour On Tue, Mar 3, 2009 at 11:11 PM, Meinrad Recheis <meinrad.recheis at gmail.com<mailto:meinrad.recheis at gmail.com>> wrote: On Tue, Mar 3, 2009 at 9:46 PM, Thibaut Barr?re <thibaut.barrere at gmail.com<mailto:thibaut.barrere at gmail.com>> wrote: Hi, while writing specs for Magic, I noticed that: instance_from(MenuItem, "Hello").text.to_s.should == "Hello" to_s is required to get the assertion to pass. The following will return false: button = Button.new button.text = "Hello" puts button.text == "Hello" So I guess that CLR strings cannot be compared to Ruby strings unless to_s is applied. I have stumbled on this too and was very surprised. This problem does not exist in IronPython (does it? please correct me if I am wrong). The behavior I was expecting is that "on the ruby" side all strings are (or at least behave exactly like) ruby strings, even if they come from .NET and are automatically converted to clr-strings when passed into clr methods. In addition to that, it would also be great to have automatic type conversion on the .NET side too. I''d expect to be able to assign a string pulled out from the interpreter to a C# string without the need to call ToString(). For example, string s = engine.Execute("''hi''") as string; Currently s would be null because the dynamic cast to System.String fails. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090303/e4124e4e/attachment.html>
Jimmy Schementi
2009-Mar-03 22:49 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
IronPython doesn''t have this problem because they use CLR Strings directly; Python strings map well to CLR Strings. Ruby has mutable strings, and CLR Strings are immutable, so IronRuby strings are different types than CLR Strings. Comparison of CLR Strings and Ruby Strings should be possible without having to to_s a CLR string ... so this is a bug and on our list of .NET interop things to do. We won''t do an auto-conversion of CLR strings to Ruby strings, since a CLR method may return a string that you want to pass onto another CLR method. However, we do convert Ruby strings to CLR strings today. ~js From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis Sent: Tuesday, March 03, 2009 2:12 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour On Tue, Mar 3, 2009 at 9:46 PM, Thibaut Barr?re <thibaut.barrere at gmail.com<mailto:thibaut.barrere at gmail.com>> wrote: Hi, while writing specs for Magic, I noticed that: instance_from(MenuItem, "Hello").text.to_s.should == "Hello" to_s is required to get the assertion to pass. The following will return false: button = Button.new button.text = "Hello" puts button.text == "Hello" So I guess that CLR strings cannot be compared to Ruby strings unless to_s is applied. I have stumbled on this too and was very surprised. This problem does not exist in IronPython (does it? please correct me if I am wrong). The behavior I was expecting is that "on the ruby" side all strings are (or at least behave exactly like) ruby strings, even if they come from .NET and are automatically converted to clr-strings when passed into clr methods. cheers, -- henon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090303/4380ebad/attachment.html>
Thibaut Barrère
2009-Mar-03 23:05 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
> Comparison of CLR Strings and Ruby Strings should be possible without having > to to_s a CLR string ... so this is a bug and on our list of .NET interop > things to do. We won''t do an auto-conversion of CLR strings to Ruby strings, > since a CLR method may return a string that you want to pass onto another > CLR method. However, we do convert Ruby strings to CLR strings today.Just removing the need for to_s when comparing sounds good to me. thanks for the feedback, -- Thibaut> > > > ~js > > > > From: ironruby-core-bounces at rubyforge.org > [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis > Sent: Tuesday, March 03, 2009 2:12 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > > > On Tue, Mar 3, 2009 at 9:46 PM, Thibaut Barr?re <thibaut.barrere at gmail.com> > wrote: > > Hi, > > while writing specs for Magic, I noticed that: > > instance_from(MenuItem, "Hello").text.to_s.should == "Hello" > > to_s is required to get the assertion to pass. The following will return > false: > > > > button = Button.new > > button.text = "Hello" > > puts button.text == "Hello" > > > > So I guess that CLR strings cannot be compared to Ruby strings unless to_s > is applied. > > > > I have stumbled on this too and was very surprised. This problem does not > exist in IronPython (does it? please correct me if I am wrong). The behavior > I was expecting is that "on the ruby" side all strings are (or at least > behave exactly like) ruby strings, even if they come from .NET and are > automatically converted to clr-strings when passed into clr methods. > > > > cheers, > -- henon > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >
Tomas Matousek
2009-Mar-03 23:24 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
We don''t plan to make the highlighted code work. However we are going to make this work: string s = engine.Execute<string>("''hi''") and also this works: string s = engine.Execute("''hi''").ToString(), although in this case you need to take care of null. The difference is that unlike Execute, Execute<T> invokes an explicit dynamic conversion on the resulting type. You can achieve the same using engine.ObjectOperations.ConvertTo<string>(engine.Execute("''hi''")). Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis Sent: Tuesday, March 03, 2009 2:19 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour On Tue, Mar 3, 2009 at 11:11 PM, Meinrad Recheis <meinrad.recheis at gmail.com<mailto:meinrad.recheis at gmail.com>> wrote: On Tue, Mar 3, 2009 at 9:46 PM, Thibaut Barr?re <thibaut.barrere at gmail.com<mailto:thibaut.barrere at gmail.com>> wrote: Hi, while writing specs for Magic, I noticed that: instance_from(MenuItem, "Hello").text.to_s.should == "Hello" to_s is required to get the assertion to pass. The following will return false: button = Button.new button.text = "Hello" puts button.text == "Hello" So I guess that CLR strings cannot be compared to Ruby strings unless to_s is applied. I have stumbled on this too and was very surprised. This problem does not exist in IronPython (does it? please correct me if I am wrong). The behavior I was expecting is that "on the ruby" side all strings are (or at least behave exactly like) ruby strings, even if they come from .NET and are automatically converted to clr-strings when passed into clr methods. In addition to that, it would also be great to have automatic type conversion on the .NET side too. I''d expect to be able to assign a string pulled out from the interpreter to a C# string without the need to call ToString(). For example, string s = engine.Execute("''hi''") as string; Currently s would be null because the dynamic cast to System.String fails. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090303/87658238/attachment.html>
Meinrad Recheis
2009-Mar-04 00:24 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Ok, the Execute<T> is convenient enough. In my opinion the highlighted C# code represents a potential interoperability pitfall and will need to be documented well. On the ruby side, I think there are no technical limitations to achieve ruby''s string behavior even if the underlying object is an immutable clr string. What do you think? -- henon On Wed, Mar 4, 2009 at 12:24 AM, Tomas Matousek < Tomas.Matousek at microsoft.com> wrote:> We don?t plan to make the highlighted code work. However we are going to > make this work: > > > > string s = engine.Execute<string>(??hi??) > > > > and also this works: > > > > string s = engine.Execute(??hi??).ToString(), > > > > although in this case you need to take care of *null*. > > > > The difference is that unlike Execute, Execute<T> invokes an explicit > dynamic conversion on the resulting type. You can achieve the same using > engine.ObjectOperations.ConvertTo<string>(engine.Execute(??hi??)). > > > > Tomas >[...]> In addition to that, it would also be great to have automatic type > conversion on the .NET side too. I''d expect to be able to assign a string > pulled out from the interpreter to a C# string without the need to call > ToString(). For example, > > string s = engine.Execute("''hi''") as string; > > Currently s would be null because the dynamic cast to System.String fails. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090304/9e713685/attachment.html>
Jimmy Schementi
2009-Mar-04 06:08 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
(This is my understanding of the problem, so Tomas please correct me if it''s wrong ... I wasn''t involved in the initial decision). The "mutableness" of a string is the defining distinction, so we don''t make CLR string act like a Ruby string in cases, because it won''t allow mutation. This is the same reason we can''t easily allow Ruby methods to operate on CLR strings, because mutating methods won''t work (chomp!, etc). So rather than only supporting part of the Ruby methods on CLR strings, you have to explicitly ask for one or the other. In practice, I haven''t felt much pain by this when hosting IronRuby. The hosting layer can make sure to convert any CLR string into a mutable string, and any strings pulled out of IronRuby code can be turned into CLR strings by the way Tomas showed below. ~js From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis Sent: Tuesday, March 03, 2009 4:25 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour Ok, the Execute<T> is convenient enough. In my opinion the highlighted C# code represents a potential interoperability pitfall and will need to be documented well. On the ruby side, I think there are no technical limitations to achieve ruby''s string behavior even if the underlying object is an immutable clr string. What do you think? -- henon On Wed, Mar 4, 2009 at 12:24 AM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: We don''t plan to make the highlighted code work. However we are going to make this work: string s = engine.Execute<string>("''hi''") and also this works: string s = engine.Execute("''hi''").ToString(), although in this case you need to take care of null. The difference is that unlike Execute, Execute<T> invokes an explicit dynamic conversion on the resulting type. You can achieve the same using engine.ObjectOperations.ConvertTo<string>(engine.Execute("''hi''")). Tomas [...] In addition to that, it would also be great to have automatic type conversion on the .NET side too. I''d expect to be able to assign a string pulled out from the interpreter to a C# string without the need to call ToString(). For example, string s = engine.Execute("''hi''") as string; Currently s would be null because the dynamic cast to System.String fails. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090303/892ec578/attachment.html>
Tomas Matousek
2009-Mar-04 08:03 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Apart from being mutable they also carry an encoding along. Ruby string is basically a resizable byte array with an encoding. CLR strings are actually closer to Ruby symbols than to Ruby strings. So we have two options on the Ruby side: either to implement the same set of methods Symbol has or a subset of String methods that don''t mutate the string. Since Ruby doesn''t provide many useful methods on Symbol it might be better to choose the latter. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jimmy Schementi Sent: Tuesday, March 03, 2009 10:09 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour (This is my understanding of the problem, so Tomas please correct me if it''s wrong ... I wasn''t involved in the initial decision). The "mutableness" of a string is the defining distinction, so we don''t make CLR string act like a Ruby string in cases, because it won''t allow mutation. This is the same reason we can''t easily allow Ruby methods to operate on CLR strings, because mutating methods won''t work (chomp!, etc). So rather than only supporting part of the Ruby methods on CLR strings, you have to explicitly ask for one or the other. In practice, I haven''t felt much pain by this when hosting IronRuby. The hosting layer can make sure to convert any CLR string into a mutable string, and any strings pulled out of IronRuby code can be turned into CLR strings by the way Tomas showed below. ~js From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis Sent: Tuesday, March 03, 2009 4:25 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour Ok, the Execute<T> is convenient enough. In my opinion the highlighted C# code represents a potential interoperability pitfall and will need to be documented well. On the ruby side, I think there are no technical limitations to achieve ruby''s string behavior even if the underlying object is an immutable clr string. What do you think? -- henon On Wed, Mar 4, 2009 at 12:24 AM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: We don''t plan to make the highlighted code work. However we are going to make this work: string s = engine.Execute<string>("''hi''") and also this works: string s = engine.Execute("''hi''").ToString(), although in this case you need to take care of null. The difference is that unlike Execute, Execute<T> invokes an explicit dynamic conversion on the resulting type. You can achieve the same using engine.ObjectOperations.ConvertTo<string>(engine.Execute("''hi''")). Tomas [...] In addition to that, it would also be great to have automatic type conversion on the .NET side too. I''d expect to be able to assign a string pulled out from the interpreter to a C# string without the need to call ToString(). For example, string s = engine.Execute("''hi''") as string; Currently s would be null because the dynamic cast to System.String fails. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090304/2f6c430a/attachment-0001.html>
Thibaut Barrère
2009-Mar-04 08:54 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Hi guys, thanks for the discussion. I really understand how tricky this can be from an infrastructure point of view. I raised this point because I pretty much believe the question is going to come over again and again from newcomers. My feeling (although I understand what''s happening under the cover) is that it breaks the POLS a bit, and that people using IronRuby for the first time could find it somewhat "flaky" (aaah, it''s an interop thingy, ok). Just my opinion - if it stays the same, a red bold entry in the FAQs will be useful :) In the code itself, I don''t believe this kind of comparison will be so common, and a .to_s will not necessarily hurt. For people that write tests/specs though, it clutters the code quite a bit. So when running tests, I think my solution will be to patch System::String to avoid cluttering the specs with .to_s calls. I''ll share it here if I come to something that works for me. cheers and thanks for the discussion, appreciated, -- Thibaut On Wed, Mar 4, 2009 at 9:03 AM, Tomas Matousek <Tomas.Matousek at microsoft.com> wrote:> Apart from being mutable they also carry an encoding along. Ruby string is > basically a resizable byte array with an encoding. > > > > CLR strings are actually closer to Ruby symbols than to Ruby strings. So we > have two options on the Ruby side: either to implement the same set of > methods Symbol has or a subset of String methods that don?t mutate the > string. Since Ruby doesn?t provide many useful methods on Symbol it might be > better to choose the latter. > > > > Tomas > > > > From: ironruby-core-bounces at rubyforge.org > [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jimmy Schementi > Sent: Tuesday, March 03, 2009 10:09 PM > > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > > > (This is my understanding of the problem, so Tomas please correct me if it?s > wrong ? I wasn?t involved in the initial decision). > > > > The ?mutableness? of a string is the defining distinction, so we don?t make > CLR string act like a Ruby string in cases, because it won?t allow mutation. > This is the same reason we can?t easily allow Ruby methods to operate on CLR > strings, because mutating methods won?t work (chomp!, etc). So rather than > only supporting part of the Ruby methods on CLR strings, you have to > explicitly ask for one or the other. > > > > In practice, I haven?t felt much pain by this when hosting IronRuby. The > hosting layer can make sure to convert any CLR string into a mutable string, > and any strings pulled out of IronRuby code can be turned into CLR strings > by the way Tomas showed below. > > > > ~js > > > > From: ironruby-core-bounces at rubyforge.org > [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis > Sent: Tuesday, March 03, 2009 4:25 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > > > Ok, the Execute<T> is convenient enough. In my opinion the highlighted C# > code represents a potential interoperability pitfall and will need to be > documented well. > > On the ruby side, I think there are no technical limitations to achieve > ruby''s string behavior even if the underlying object is an immutable clr > string. What do you think? > > -- henon > > On Wed, Mar 4, 2009 at 12:24 AM, Tomas Matousek > <Tomas.Matousek at microsoft.com> wrote: > > We don?t plan to make the highlighted code work. However we are going to > make this work: > > > > string s = engine.Execute<string>(??hi??) > > > > and also this works: > > > > string s = engine.Execute(??hi??).ToString(), > > > > although in this case you need to take care of null. > > > > The difference is that unlike Execute, Execute<T> invokes an explicit > dynamic conversion on the resulting type. You can achieve the same using > engine.ObjectOperations.ConvertTo<string>(engine.Execute(??hi??)). > > > > Tomas > > > > [...] > > In addition to that, it would also be great to have automatic type > conversion on the .NET side too. I''d expect to be able to assign a string > pulled out from the interpreter to a C# string without the need to call > ToString(). For example, > > string s = engine.Execute("''hi''") as string; > > Currently s would be null because the dynamic cast to System.String fails. > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >
Meinrad Recheis
2009-Mar-04 19:18 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
On Wed, Mar 4, 2009 at 9:03 AM, Tomas Matousek <Tomas.Matousek at microsoft.com> wrote:> Apart from being mutable they also carry an encoding along. Ruby string > is basically a resizable byte array with an encoding. > > > > CLR strings are actually closer to Ruby symbols than to Ruby strings. So we > have two options on the Ruby side: either to implement the same set of > methods Symbol has or a subset of String methods that don?t mutate the > string. Since Ruby doesn?t provide many useful methods on Symbol it might be > better to choose the latter. > > > > Tomas >I was thinking the same direction ;). I know, the current design has already been decided and it''d be painful to change it. But I am curious if you thought about the option to actually use clr strings and copy them whenever any muting methods have been called. Would solve the compatibility problem but I guess this might have too bad performance impact on existing library code? The problem exists only where strings cross the language boundary (from Ruby to C# or vice versa). There would be the option to strictly convert strings into the expected format each time they cross the boundary. I guess this might also be too costly. Finally a thought about the consequences of the current string incompatibility: I can imagine situations where either clr_strings that "leak" from .Net into ruby library code or ruby strings that "leak" into .NET code might cause bugs which are hard to track down. I was once fooled by the debugger ... thought I got a System.String but it actually was a Mutable string because they exactly look alike. It took some time until I found out what was going on. -- henon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090304/a7341976/attachment.html>
Tomas Matousek
2009-Mar-04 19:54 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
We can differentiate #inspect on CLR string to print something like i"xxx" ("i" for immutable) or clr:"xxx" ... We can also implement some default conversions, like to_s where it makes sense. We can''t use CLR strings and make copies since that don''t preserve object identity and type (note that we need to also switch between Unicode char[] and byte[]). We also need to attach some information with the string (encoding, frozen and tainted flags), so it couldn''t be just System.String anyways. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis Sent: Wednesday, March 04, 2009 11:19 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour On Wed, Mar 4, 2009 at 9:03 AM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: Apart from being mutable they also carry an encoding along. Ruby string is basically a resizable byte array with an encoding. CLR strings are actually closer to Ruby symbols than to Ruby strings. So we have two options on the Ruby side: either to implement the same set of methods Symbol has or a subset of String methods that don''t mutate the string. Since Ruby doesn''t provide many useful methods on Symbol it might be better to choose the latter. Tomas I was thinking the same direction ;). I know, the current design has already been decided and it''d be painful to change it. But I am curious if you thought about the option to actually use clr strings and copy them whenever any muting methods have been called. Would solve the compatibility problem but I guess this might have too bad performance impact on existing library code? The problem exists only where strings cross the language boundary (from Ruby to C# or vice versa). There would be the option to strictly convert strings into the expected format each time they cross the boundary. I guess this might also be too costly. Finally a thought about the consequences of the current string incompatibility: I can imagine situations where either clr_strings that "leak" from .Net into ruby library code or ruby strings that "leak" into .NET code might cause bugs which are hard to track down. I was once fooled by the debugger ... thought I got a System.String but it actually was a Mutable string because they exactly look alike. It took some time until I found out what was going on. -- henon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090304/04adfad1/attachment-0001.html>
Shri Borde
2009-Mar-04 20:11 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
I think System.String should support the non-mutating methods of Ruby String class (second option Tomas mentioned). We enhance other CLR types with the Ruby equivalent functionality (like System.Collections.IEnumerable to Enumerable, all CLR types support Ruby Object and Kernel methods like #class, etc). http://www.ironruby.net/About/Roadmap already mentions supporting to_s on all CLR types anyway. Why would we need to do anything special for System.String? Mutating operations will fail which could be surprising. We can address this by throwing good error messages indicating that the user has to explicitly convert it to a Ruby string. I like the idea of showing System.String as clr:"xxx". Thanks, Shri From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek Sent: Wednesday, March 04, 2009 11:54 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour We can differentiate #inspect on CLR string to print something like i"xxx" ("i" for immutable) or clr:"xxx" ... We can also implement some default conversions, like to_s where it makes sense. We can''t use CLR strings and make copies since that don''t preserve object identity and type (note that we need to also switch between Unicode char[] and byte[]). We also need to attach some information with the string (encoding, frozen and tainted flags), so it couldn''t be just System.String anyways. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis Sent: Wednesday, March 04, 2009 11:19 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour On Wed, Mar 4, 2009 at 9:03 AM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: Apart from being mutable they also carry an encoding along. Ruby string is basically a resizable byte array with an encoding. CLR strings are actually closer to Ruby symbols than to Ruby strings. So we have two options on the Ruby side: either to implement the same set of methods Symbol has or a subset of String methods that don''t mutate the string. Since Ruby doesn''t provide many useful methods on Symbol it might be better to choose the latter. Tomas I was thinking the same direction ;). I know, the current design has already been decided and it''d be painful to change it. But I am curious if you thought about the option to actually use clr strings and copy them whenever any muting methods have been called. Would solve the compatibility problem but I guess this might have too bad performance impact on existing library code? The problem exists only where strings cross the language boundary (from Ruby to C# or vice versa). There would be the option to strictly convert strings into the expected format each time they cross the boundary. I guess this might also be too costly. Finally a thought about the consequences of the current string incompatibility: I can imagine situations where either clr_strings that "leak" from .Net into ruby library code or ruby strings that "leak" into .NET code might cause bugs which are hard to track down. I was once fooled by the debugger ... thought I got a System.String but it actually was a Mutable string because they exactly look alike. It took some time until I found out what was going on. -- henon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090304/e0a30c5f/attachment.html>
Thibaut Barrère
2009-Mar-04 20:14 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
> I like the idea of showing System.String as clr:?xxx?.+1 for something like that - this way the failed assertions or people using stdout for debug would not be fooled. -- Thibaut
Jim Deville
2009-Mar-04 21:06 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Agreed. JD> -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core- > bounces at rubyforge.org] On Behalf Of Thibaut Barr?re > Sent: Wednesday, March 04, 2009 12:15 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > > I like the idea of showing System.String as clr:"xxx". > > +1 for something like that - this way the failed assertions or people > using stdout for debug would not be fooled. > > -- Thibaut > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core
Tinco Andringa
2009-Mar-04 22:26 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
>From what I get from this conversation, the ruby strings are stringswith a few extra features (mutability, carrying encoding). Wouldn''t it be logical for the ruby muteable strings to extend System.String? Are there methods that only work on .net strings and not on ruby strings? Forgive me if this is a stupid question, I''m not very well educated in how muteable strings work :) -- Tinco
Tomas Matousek
2009-Mar-05 21:03 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
I''m going to use single quotes for formatting CLR strings via inspect. "clr:" prefix is too long and it gets in your way when working mostly with CLR strings.>>> "Some string"=> "Some string">>> "Some string".to_clr_string=> ''Some string'' Sounds good? Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Thibaut Barr?re Sent: Wednesday, March 04, 2009 12:15 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour> I like the idea of showing System.String as clr:"xxx".+1 for something like that - this way the failed assertions or people using stdout for debug would not be fooled. -- Thibaut _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Pete Bacon Darwin
2009-Mar-05 21:21 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
How about back ticks? `Some string`? Since ruby can have single quote string literals it might not be that obvious that ''Some string'' it is not a normal Ruby string. Pete -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek Sent: Thursday,05 March 05, 2009 21:03 To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour I''m going to use single quotes for formatting CLR strings via inspect. "clr:" prefix is too long and it gets in your way when working mostly with CLR strings.>>> "Some string"=> "Some string">>> "Some string".to_clr_string=> ''Some string'' Sounds good? Tomas
Meinrad Recheis
2009-Mar-05 21:45 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
On Thu, Mar 5, 2009 at 10:03 PM, Tomas Matousek < Tomas.Matousek at microsoft.com> wrote:> I''m going to use single quotes for formatting CLR strings via inspect. > "clr:" prefix is too long and it gets in your way when working mostly with > CLR strings. > > >>> "Some string" > => "Some string" > >>> "Some string".to_clr_string > => ''Some string'' > > Sounds good?The obvious advantage is that this representation is a valid ruby expression. -- henon -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090305/e1a46b80/attachment.html>
Orion Edwards
2009-Mar-05 22:00 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
I like backticks more than single quotes, but ideally you''d just have the same quotes and make them red or something for clr strings. On Fri, Mar 6, 2009 at 10:21 AM, Pete Bacon Darwin < bacondarwin at googlemail.com> wrote:> How about back ticks? `Some string`? > > Since ruby can have single quote string literals it might not be that > obvious that ''Some string'' it is not a normal Ruby string. > > Pete > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org > [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek > Sent: Thursday,05 March 05, 2009 21:03 > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > I''m going to use single quotes for formatting CLR strings via inspect. > "clr:" prefix is too long and it gets in your way when working mostly with > CLR strings. > > >>> "Some string" > => "Some string" > >>> "Some string".to_clr_string > => ''Some string'' > > Sounds good? > > Tomas > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090306/0c380f28/attachment.html>
Meinrad Recheis
2009-Mar-05 22:37 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Back ticks have a different meaning in ruby. They denote code to be executed on the system shell. -- henon On Thu, Mar 5, 2009 at 10:21 PM, Pete Bacon Darwin < bacondarwin at googlemail.com> wrote:> How about back ticks? `Some string`? > > Since ruby can have single quote string literals it might not be that > obvious that ''Some string'' it is not a normal Ruby string. > > Pete > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org > [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek > Sent: Thursday,05 March 05, 2009 21:03 > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > I''m going to use single quotes for formatting CLR strings via inspect. > "clr:" prefix is too long and it gets in your way when working mostly with > CLR strings. > > >>> "Some string" > => "Some string" > >>> "Some string".to_clr_string > => ''Some string'' > > Sounds good? > > Tomas > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090305/53c9d6f9/attachment.html>
Tomas Matousek
2009-Mar-05 22:41 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Ruby uses back-ticks for shell strings, so it doesn''t seem to be more obvious that the value is CLR string. I agree it''s not blatant. It''s a small hint that should help you to distinguish the types. CLR strings will have most of the methods Ruby string have (except for mutable ones) so the difference is not so important in most scenarios. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Pete Bacon Darwin Sent: Thursday, March 05, 2009 1:22 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour How about back ticks? `Some string`? Since ruby can have single quote string literals it might not be that obvious that ''Some string'' it is not a normal Ruby string. Pete -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek Sent: Thursday,05 March 05, 2009 21:03 To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour I''m going to use single quotes for formatting CLR strings via inspect. "clr:" prefix is too long and it gets in your way when working mostly with CLR strings.>>> "Some string"=> "Some string">>> "Some string".to_clr_string=> ''Some string'' Sounds good? Tomas _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Tinco Andringa
2009-Mar-06 02:26 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Wouldn''t using different syntax especially for clr just amount to creating a new language instead of implementing Ruby on the dlr? (Not to mention a language that''s not very intuitive) On Thu, Mar 5, 2009 at 23:00, Orion Edwards <orion.edwards at gmail.com> wrote:> I like backticks more than single quotes, but ideally you''d just have the > same quotes and make them red or something for clr strings. > > On Fri, Mar 6, 2009 at 10:21 AM, Pete Bacon Darwin > <bacondarwin at googlemail.com> wrote: >> >> How about back ticks? `Some string`? >> >> Since ruby can have single quote string literals it might not be that >> obvious that ''Some string'' it is not a normal Ruby string. >> >> Pete >> >> -----Original Message----- >> From: ironruby-core-bounces at rubyforge.org >> [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek >> Sent: Thursday,05 March 05, 2009 21:03 >> To: ironruby-core at rubyforge.org >> Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a >> slightly surprising behaviour >> >> I''m going to use single quotes for formatting CLR strings via inspect. >> "clr:" prefix is too long and it gets in your way when working mostly with >> CLR strings. >> >> >>> "Some string" >> => "Some string" >> >>> "Some string".to_clr_string >> => ''Some string'' >> >> Sounds good? >> >> Tomas >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >
Tomas Matousek
2009-Mar-06 06:04 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
This is not about syntax. This is just what System::String#inspect prints out. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tinco Andringa Sent: Thursday, March 05, 2009 6:26 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour Wouldn''t using different syntax especially for clr just amount to creating a new language instead of implementing Ruby on the dlr? (Not to mention a language that''s not very intuitive) On Thu, Mar 5, 2009 at 23:00, Orion Edwards <orion.edwards at gmail.com> wrote:> I like backticks more than single quotes, but ideally you''d just have the > same quotes and make them red or something for clr strings. > > On Fri, Mar 6, 2009 at 10:21 AM, Pete Bacon Darwin > <bacondarwin at googlemail.com> wrote: >> >> How about back ticks? `Some string`? >> >> Since ruby can have single quote string literals it might not be that >> obvious that ''Some string'' it is not a normal Ruby string. >> >> Pete >> >> -----Original Message----- >> From: ironruby-core-bounces at rubyforge.org >> [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek >> Sent: Thursday,05 March 05, 2009 21:03 >> To: ironruby-core at rubyforge.org >> Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a >> slightly surprising behaviour >> >> I''m going to use single quotes for formatting CLR strings via inspect. >> "clr:" prefix is too long and it gets in your way when working mostly with >> CLR strings. >> >> >>> "Some string" >> => "Some string" >> >>> "Some string".to_clr_string >> => ''Some string'' >> >> Sounds good? >> >> Tomas >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >_______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Meinrad Recheis
2009-Mar-06 07:46 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Well, it slightly relates to syntax ... because basic ruby types (string, numeric, array, hash, range, etc.) use to print valid ruby syntax on inspect. This is very useful for reinterpreting values stored as strings by the use of inspect. -- henon On Fri, Mar 6, 2009 at 7:04 AM, Tomas Matousek <Tomas.Matousek at microsoft.com> wrote:> This is not about syntax. This is just what System::String#inspect prints > out. > > Tomas > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] On Behalf Of Tinco Andringa > Sent: Thursday, March 05, 2009 6:26 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > Wouldn''t using different syntax especially for clr just amount to > creating a new language instead of implementing Ruby on the dlr? (Not > to mention a language that''s not very intuitive) > > On Thu, Mar 5, 2009 at 23:00, Orion Edwards <orion.edwards at gmail.com> > wrote: > > I like backticks more than single quotes, but ideally you''d just have the > > same quotes and make them red or something for clr strings. > > > > On Fri, Mar 6, 2009 at 10:21 AM, Pete Bacon Darwin > > <bacondarwin at googlemail.com> wrote: > >> > >> How about back ticks? `Some string`? > >> > >> Since ruby can have single quote string literals it might not be that > >> obvious that ''Some string'' it is not a normal Ruby string. > >> > >> Pete > >> > >> -----Original Message----- > >> From: ironruby-core-bounces at rubyforge.org > >> [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas > Matousek > >> Sent: Thursday,05 March 05, 2009 21:03 > >> To: ironruby-core at rubyforge.org > >> Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > >> slightly surprising behaviour > >> > >> I''m going to use single quotes for formatting CLR strings via inspect. > >> "clr:" prefix is too long and it gets in your way when working mostly > with > >> CLR strings. > >> > >> >>> "Some string" > >> => "Some string" > >> >>> "Some string".to_clr_string > >> => ''Some string'' > >> > >> Sounds good? > >> > >> Tomas > >> > >> _______________________________________________ > >> Ironruby-core mailing list > >> Ironruby-core at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/ironruby-core > > > > > > _______________________________________________ > > Ironruby-core mailing list > > Ironruby-core at rubyforge.org > > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090306/be916d22/attachment-0001.html>
Tomas Matousek
2009-Mar-06 17:45 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Syste::String is not a basic Ruby type. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Meinrad Recheis Sent: Thursday, March 05, 2009 11:47 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour Well, it slightly relates to syntax ... because basic ruby types (string, numeric, array, hash, range, etc.) use to print valid ruby syntax on inspect. This is very useful for reinterpreting values stored as strings by the use of inspect. -- henon On Fri, Mar 6, 2009 at 7:04 AM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: This is not about syntax. This is just what System::String#inspect prints out. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Tinco Andringa Sent: Thursday, March 05, 2009 6:26 PM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour Wouldn''t using different syntax especially for clr just amount to creating a new language instead of implementing Ruby on the dlr? (Not to mention a language that''s not very intuitive) On Thu, Mar 5, 2009 at 23:00, Orion Edwards <orion.edwards at gmail.com<mailto:orion.edwards at gmail.com>> wrote:> I like backticks more than single quotes, but ideally you''d just have the > same quotes and make them red or something for clr strings. > > On Fri, Mar 6, 2009 at 10:21 AM, Pete Bacon Darwin > <bacondarwin at googlemail.com<mailto:bacondarwin at googlemail.com>> wrote: >> >> How about back ticks? `Some string`? >> >> Since ruby can have single quote string literals it might not be that >> obvious that ''Some string'' it is not a normal Ruby string. >> >> Pete >> >> -----Original Message----- >> From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> >> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Tomas Matousek >> Sent: Thursday,05 March 05, 2009 21:03 >> To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> >> Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a >> slightly surprising behaviour >> >> I''m going to use single quotes for formatting CLR strings via inspect. >> "clr:" prefix is too long and it gets in your way when working mostly with >> CLR strings. >> >> >>> "Some string" >> => "Some string" >> >>> "Some string".to_clr_string >> => ''Some string'' >> >> Sounds good? >> >> Tomas >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> >> http://rubyforge.org/mailman/listinfo/ironruby-core > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> > http://rubyforge.org/mailman/listinfo/ironruby-core > >_______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090306/ebc46fbe/attachment-0001.html>
Jimmy Schementi
2009-Mar-06 18:36 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
>> "rm -Rf *".to_clr_string=> `rm -Rf *` Copying and pasting that result would lead to bad things =P ... so I say no back ticks. Let''s stick with single quotes ... it''s not a difficult thing to change in the future. ~js> -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core- > bounces at rubyforge.org] On Behalf Of Pete Bacon Darwin > Sent: Thursday, March 05, 2009 1:22 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > How about back ticks? `Some string`? > > Since ruby can have single quote string literals it might not be that > obvious that ''Some string'' it is not a normal Ruby string. > > Pete > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org > [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas > Matousek > Sent: Thursday,05 March 05, 2009 21:03 > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > I''m going to use single quotes for formatting CLR strings via inspect. > "clr:" prefix is too long and it gets in your way when working mostly > with > CLR strings. > > >>> "Some string" > => "Some string" > >>> "Some string".to_clr_string > => ''Some string'' > > Sounds good? > > Tomas > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core
Pete Bacon Darwin
2009-Mar-06 19:29 UTC
[Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour
Fair enough! -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jimmy Schementi Sent: Friday,06 March 06, 2009 18:36 To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a slightly surprising behaviour>> "rm -Rf *".to_clr_string=> `rm -Rf *` Copying and pasting that result would lead to bad things =P ... so I say no back ticks. Let''s stick with single quotes ... it''s not a difficult thing to change in the future. ~js> -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core- > bounces at rubyforge.org] On Behalf Of Pete Bacon Darwin > Sent: Thursday, March 05, 2009 1:22 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > How about back ticks? `Some string`? > > Since ruby can have single quote string literals it might not be that > obvious that ''Some string'' it is not a normal Ruby string. > > Pete > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org > [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas > Matousek > Sent: Thursday,05 March 05, 2009 21:03 > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Comparing CLR strings and Ruby strings - a > slightly surprising behaviour > > I''m going to use single quotes for formatting CLR strings via inspect. > "clr:" prefix is too long and it gets in your way when working mostly > with > CLR strings. > > >>> "Some string" > => "Some string" > >>> "Some string".to_clr_string > => ''Some string'' > > Sounds good? > > Tomas > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core_______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core