Professional Web Applications Themes

Can't marshal MatchData? - Ruby

Folks, I understand there are 4 kinds of things you can't marshal: singleton methods, IO objects, bindings, and ... and ... someone will fill in. Why then, can't you marshal MatchData objects? To wit: irb(main):108:0> Marshal.dump(ms[63]).size TypeError: can't dump MatchData from (irb):108:in `dump' from (irb):108 from ?:0 [ms is an array of MatchData objects] I don't think MatchData is the fourth item in the incomplete list above. Gavin...

  1. #1

    Default Can't marshal MatchData?

    Folks,

    I understand there are 4 kinds of things you can't marshal: singleton
    methods, IO objects, bindings, and ... and ... someone will fill in.

    Why then, can't you marshal MatchData objects? To wit:

    irb(main):108:0> Marshal.dump(ms[63]).size
    TypeError: can't dump MatchData
    from (irb):108:in `dump'
    from (irb):108
    from ?:0

    [ms is an array of MatchData objects]

    I don't think MatchData is the fourth item in the incomplete list above.

    Gavin



    Gavin Sinclair Guest

  2. #2

    Default Re: Can't marshal MatchData?

    On Wed, Aug 06, 2003 at 05:34:47PM +0900, Gavin Sinclair wrote:
    > Folks,
    >
    > I understand there are 4 kinds of things you can't marshal: singleton
    > methods, IO objects, bindings, and ... and ... someone will fill in.
    procs ?
    > I don't think MatchData is the fourth item in the incomplete list above.
    Maybe it's the fifth :-)

    Regards,

    Brian.

    Brian Candler Guest

  3. #3

    Default Re: Can't marshal MatchData?


    "Gavin Sinclair" <gsinclairsoyabean.com.au> schrieb im Newsbeitrag
    news:48928.203.185.214.34.1060113020.squirrelwebm ail.imagineis.com...
    > Folks,
    >
    > I understand there are 4 kinds of things you can't marshal: singleton
    > methods, IO objects, bindings, and ... and ... someone will fill in.
    >
    > Why then, can't you marshal MatchData objects? To wit:
    >
    > irb(main):108:0> Marshal.dump(ms[63]).size
    > TypeError: can't dump MatchData
    > from (irb):108:in `dump'
    > from (irb):108
    > from ?:0
    >
    > [ms is an array of MatchData objects]
    >
    > I don't think MatchData is the fourth item in the incomplete list above.
    Maybe a Regexp reuses the same MatchData instance through all matches
    (this saves instantiations). If that were the case it would not make much
    sense marshalling a MatchData instance. Instead one should probably
    convert it into an array.

    Just my 5eurocent...

    robert

    Robert Klemme Guest

  4. #4

    Default Re: Can't marshal MatchData?

    On Wednesday, August 6, 2003, 7:42:01 PM, Robert wrote:
    > Maybe a Regexp reuses the same MatchData instance through all matches
    > (this saves instantiations). If that were the case it would not make much
    > sense marshalling a MatchData instance. Instead one should probably
    > convert it into an array.
    I didn't really want to store them, I was just mucking around, so I'm
    not going to argue on practical grounds. However, Matchdata offer
    useful properties: the string that was searched, the pre- and
    post-matches.

    I imagine there is some optimisation going on behind the scenes:
    MatchData#string returns a frozen String, so it can certainly be
    shared among many MatchData objects. #pre_match appears to return a
    copy of the pre-match, as modifiying its return value does not affect
    subsequent calls.

    All academic, anyway...

    Gavin


    Gavin Sinclair Guest

Similar Threads

  1. Marshal.GetActiveObject throws an exception in a C# webservice but
    By OfurGørn in forum ASP.NET Web Services
    Replies: 30
    Last Post: February 17th, 02:47 AM
  2. Ruby 1.8 and Marshal.load/Marshal.dump
    By Michael Davis in forum Ruby
    Replies: 0
    Last Post: October 10th, 10:15 PM
  3. Marshal format "safe"?
    By Ryan Pavlik in forum Ruby
    Replies: 2
    Last Post: August 6th, 05:39 PM
  4. Marshal efficiency
    By Gavin Sinclair in forum Ruby
    Replies: 2
    Last Post: July 20th, 05:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139