REWORK - Task: Unify behaviour of by-literal-instantiated Objects

Discussion in 'Ruby' started by Ilias Lazaridis, Jun 21, 2011.

  1. (Note: This task is part of the RUBY REWORK, which has (among other
    goals) the goal to remove inconsistencies and limitations in the
    Object Model and in the language. The time frame for the overall
    rework is 3 months.)

    INTRODUCTION

    In ruby, the primitive data types are objects (instances of their
    related classes, like Integer or String)

    Ruby's object model allows modifications of a class at runtime, even
    if it is the class of a primitive data-type.

    This is official functionality of the object model, which is
    attractive, and provides flexibility - e.g. for framework design.

    As a very simple example, a "running_counter" for the String class.

    # altering the behaviour of the *original* String class, without sub-
    classing
    # this alteration is valid program wide
    class String
    @@running_counter = 0

    def initialize(val)
    @@running_counter += 1
    self.replace(val)
    end

    def running_counter
    @@running_counter
    end
    end

    #now the strings contain a running_counter, convenient accessible via
    an instance method

    oo_string = String.new("The String 1")
    p oo_string.running_counter #=> 1

    oo_string = String.new("The String 2")
    p oo_string.running_counter #=> 2

    LIMITATION

    The current implementation of ruby 1.9.2 has the following limitation:

    String objects instantiated from literals behave different.

    li_string = "The String 3"
    p li_string.running_counter #=> 2, was not incremented

    li_string = "The String 4"
    p li_string.running_counter #=> 2, was not incremented

    Although they should have the same behaviour, as they are instances of
    class String, they have a slight different behavior.

    -

    The task is, to modify the ruby interpreter, thus objects instantiated
    from literals behave like normally created objects, thus the above
    code works as expected (the redefined initialize method is called).

    Internally:

    * the C-core calls the redefined "initialize" method of an object, if
    it's available

    Implementation Requirements:

    * Minimal influence on execution speed (< 1% if feature is unused,
    interpreter dependent if feature is used )
    * Reusable functionality (future unification of object model, e.g. to
    make speed-critical items first-class-objects)

    Needed Resources:

    * time : 1 week of time
    * budget: 500,- Euro

    Needed Assistance (via emails):

    ideally:
    * Around 1 hour from a person with toolchain experiences (VC++ express
    or mingw)
    * Around 1 hour from a person which is familiar with the ruby C source
    codes
    * Around 1 hour from a person which is familiar with the ruby cross-
    platform testing


    Work Plan:

    * 1 day : setup of tool-chain (compiler, debugger, IDE)
    * 1 day : looking around in source code
    * 1 day : implementation of 1st solution
    * 1 day : implementation of 2nd solution
    * 1 day : choose solution, refactoring, tests and documentation
    * 1 day : spare day

    -

    If you would like to see this task fulfilled, and want to provide the
    mentioned assistance or part of the budget (or a means to collect the
    budget within a public system), please contact me with private email.

    -
    -
    -

    Related Issues:

    Literal Instantiation breaks Object Model
    http://redmine.ruby-lang.org/issues/4893

    Provide Class#cb_object_instantiated_from_literal(object)
    http://redmine.ruby-lang.org/issues/4845

    Unify Variable Expansion within Strings
    http://redmine.ruby-lang.org/issues/487

    ..

    --
    http://lazaridis.com
     
    Ilias Lazaridis, Jun 21, 2011
    #1
    1. Advertising

  2. On 21 Éïýí, 04:14, Ilias Lazaridis <> wrote:
    > (Note: This task is part of the RUBY REWORK, which has (among other
    > goals) the goal to remove inconsistencies and limitations in the
    > Object Model and in the language. The time frame for the overall
    > rework is 3 months.)

    [...]
    > Needed Resources:
    >
    > * time  : 1 week of time
    > * budget: 500,- Euro

    [...]
    > If you would like to see this task fulfilled, and want to provide the
    > mentioned assistance or part of the budget (or a means to collect the
    > budget within a public system), please contact me with private email.


    Clarification (for those which start to send legal nonsense via
    private email):

    The above refers to a donation-system, which I've seen for several
    open-source projects.

    It should be obvious that this RUBY REWORK is naturally based on open
    sources (BSD/Ruby licensed), and that it's more than a full-time
    commitment that (again naturally) needs a budget. The final natural
    thing is, to try to raise those budget via a public system (which
    keeps track of the donations).

    Of course you are free to suggest such a system here in this thread.

    ..

    --
    http://lazaridis.com
     
    Ilias Lazaridis, Jun 21, 2011
    #2
    1. Advertising

  3. On 21 Éïýí, 04:14, Ilias Lazaridis <> wrote:
    > (Note: This task is part of the RUBY REWORK, which has (among other
    > goals) the goal to remove inconsistencies and limitations in the
    > Object Model and in the language. The time frame for the overall
    > rework is 3 months.)

    [...]

    > The task is, to modify the ruby interpreter, thus objects instantiated
    > from literals behave like normally created objects, thus the above
    > code works as expected (the redefined initialize method is called).

    [...]

    > Needed Assistance (via emails):
    >
    > ideally:
    > * Around 1 hour from a person with toolchain experiences (VC++ express
    > or mingw)


    This is now obsolete, no assistance needed.

    > * Around 1 hour from a person which is familiar with the ruby C source
    > codes
    > * Around 1 hour from a person which is familiar with the ruby cross-
    > platform testing


    Would still like to have someone to place some questions, thus some
    time is saved.

    > Work Plan:
    >
    > * 1 day : setup of tool-chain (compiler, debugger, IDE)
    > * 1 day : looking around in source code
    > * 1 day : implementation of 1st solution
    > * 1 day : implementation of 2nd solution
    > * 1 day : choose solution, refactoring, tests and documentation
    > * 1 day : spare day


    ..

    --
    http://lazaridis.com
     
    Ilias Lazaridis, Jun 22, 2011
    #3
  4. On 21 Éïýí, 04:14, Ilias Lazaridis <> wrote:
    > (Note: This task is part of the RUBY REWORK, which has (among other
    > goals) the goal to remove inconsistencies and limitations in the
    > Object Model and in the language. The time frame for the overall
    > rework is 3 months.)

    [...]

    > The task is, to modify the ruby interpreter, thus objects instantiated
    > from literals behave like normally created objects, thus the above
    > code works as expected (the redefined initialize method is called).

    [...]

    > Needed Assistance (via emails):
    >
    > ideally:
    > * Around 1 hour from a person with toolchain experiences (VC++ express
    > or mingw)


    obsolete, no assistance needed

    > * Around 1 hour from a person which is familiar with the ruby C source
    > codes


    obsolete, no assistance needed, relevant information found within:

    http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html

    > * Around 1 hour from a person which is familiar with the ruby cross-
    > platform testing


    obsolete, no assistance needed

    (implementation will be very "thin" and need anyway a review/revision
    from the C-OO-model maintainer)

    > Work Plan:
    >
    > * 1 day : setup of tool-chain (compiler, debugger, IDE)
    > * 1 day : looking around in source code
    > * 1 day : implementation of 1st solution
    > * 1 day : implementation of 2nd solution
    > * 1 day : choose solution, refactoring, tests and documentation
    > * 1 day : spare day

    [...]

    Still, it would be nice if someone could review/test a result prior to
    submission.

    So, if you like to do so, please contact me in private.

    ..

    --
    http://lazaridis.com
     
    Ilias Lazaridis, Jun 23, 2011
    #4
  5. On 21 ΙοÏν, 04:14, Ilias Lazaridis <> wrote:
    > (Note: This task is part of the RUBY REWORK, which has (among other
    > goals) the goal to remove inconsistencies and limitations in the
    > Object Model and in the language. The time frame for the overall
    > rework is 3 months.)
    >
    > INTRODUCTION
    >
    > In ruby, the primitive data types are objects (instances of their
    > related classes, like Integer or String)
    >
    > Ruby's object model allows modifications of a class at runtime, even
    > if it is the class of a  primitive data-type.
    >
    > This is official functionality of the object model, which is
    > attractive, and provides flexibility - e.g. for framework design.
    >
    > As a very simple example, a "running_counter" for the String class.
    >
    > # altering the behaviour of the *original* String class, without sub-
    > classing
    > # this alteration is valid program wide
    > class String
    >   @@running_counter = 0
    >
    >   def initialize(val)
    >     @@running_counter += 1
    >     self.replace(val)
    >   end
    >
    >   def running_counter
    >     @@running_counter
    >   end
    > end
    >
    > #now the strings contain a running_counter, convenient accessible via
    > an instance method
    >
    > oo_string = String.new("The String 1")
    > p oo_string.running_counter #=> 1
    >
    > oo_string = String.new("The String 2")
    > p oo_string.running_counter #=> 2
    >
    > LIMITATION
    >
    > The current implementation of ruby 1.9.2 has the following limitation:
    >
    > String objects instantiated from literals behave different.
    >
    > li_string = "The String 3"
    > p li_string.running_counter #=> 2, was not incremented
    >
    > li_string = "The String 4"
    > p li_string.running_counter #=> 2, was not incremented
    >
    > Although they should have the same behaviour, as they are instances of
    > class String, they have a slight different behavior.
    >
    > -
    >
    > The task is, to modify the ruby interpreter, thus objects instantiated
    > from literals behave like normally created objects, thus the above
    > code works as expected (the redefined initialize method is called).
    >
    > Internally:
    >
    > * the C-core calls the redefined "initialize" method of an object, if
    > it's available
    >
    > Implementation Requirements:
    >
    > * Minimal influence on execution speed (< 1% if feature is unused,
    > interpreter dependent if feature is used )


    met

    > * Reusable functionality (future unification of object model, e.g. to
    > make speed-critical items first-class-objects)


    met

    > Needed Resources:
    >
    > * time  : 1 week of time


    met

    > * budget: 500,- Euro


    met (task fulfilled with 0,- Euro)

    > Needed Assistance (via emails):
    >
    > ideally:
    > * Around 1 hour from a person with toolchain experiences (VC++ express
    > or mingw)
    > * Around 1 hour from a person which is familiar with the ruby C source
    > codes
    > * Around 1 hour from a person which is familiar with the ruby cross-
    > platform testing


    not needed finally

    > Work Plan:
    >
    > * 1 day : setup of tool-chain (compiler, debugger, IDE)
    > * 1 day : looking around in source code
    > * 1 day : implementation of 1st solution
    > * 1 day : implementation of 2nd solution
    > * 1 day : choose solution, refactoring, tests and documentation
    > * 1 day : spare day
    >
    > -
    >
    > If you would like to see this task fulfilled, and want to provide the
    > mentioned assistance or part of the budget (or a means to collect the
    > budget within a public system), please contact me with private email.


    exactly 0 (zero) persons have contacted me.

    > -
    > -
    > -
    >
    > Related Issues:
    >
    > Literal Instantiation breaks Object Model
    > http://redmine.ruby-lang.org/issues/4893


    You'll find further information in the above issue.

    > Provide Class#cb_object_instantiated_from_literal(object)
    > http://redmine.ruby-lang.org/issues/4845
    >
    > Unify Variable Expansion within Strings
    > http://redmine.ruby-lang.org/issues/487


    ..

    --
    http://lazaridis.com
     
    Ilias Lazaridis, Jun 25, 2011
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. luca72
    Replies:
    2
    Views:
    343
    luca72
    Apr 28, 2006
  2. Ilias Lazaridis
    Replies:
    0
    Views:
    352
    Ilias Lazaridis
    May 20, 2006
  3. luca72

    unify els database

    luca72, Jul 2, 2007, in forum: Python
    Replies:
    4
    Views:
    302
    luca72
    Jul 9, 2007
  4. Achim Domma

    Unify datatypes of different webservices

    Achim Domma, Jul 19, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    127
    John Saunders
    Jul 20, 2006
  5. Justin C

    Module install problem DBD::Unify

    Justin C, Nov 4, 2011, in forum: Perl Misc
    Replies:
    4
    Views:
    278
    Justin C
    Nov 8, 2011
Loading...

Share This Page