Hacker News new | past | comments | ask | show | jobs | submit login

It would be nice if Ruby had a syntax for memoizing a method that would handle the nil/false case and update the shape at init time.



In a similar line, it would be nice if there were a way to predeclare instance variables so that there was a canonical place to put type annotations for instance variables. Ruby type checkers right now all invent their own ways of declaring the types of instance variables.

If Ruby supported something like

    class A
      def @instance_variable
      def self.@singleton_class_instance_variable
      def @@class_variable
    end
as a way to pre-declare the object shape at class load time, it would be an obvious place to also let type checkers declare the types of these instance variables.

(Not saying that this specific syntax is ideal, but rather just that having some syntax for declaring instance variables at load time, not method run time, would solve both the "predetermined object shape" and "predetermined ivar types" problems.)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: