[#62904] [ruby-trunk - Feature #9894] [Open] [RFC] README.EXT: document rb_gc_register_mark_object — normalperson@...
Issue #9894 has been reported by Eric Wong.
3 messages
2014/06/02
[#63321] [ANN] ElixirConf 2014 - Don't Miss Jos辿 Valim and Dave Thomas — Jim Freeze <jimfreeze@...>
Just a few more weeks until ElixirConf 2014!
6 messages
2014/06/24
[#63391] Access Modifiers (Internal Interfaces) — Daniel da Silva Ferreira <danieldasilvaferreira@...>
Hi,
3 messages
2014/06/28
[ruby-core:63434] [ruby-trunk - Feature #6806] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
From:
alexey.muranov@...
Date:
2014-06-30 13:45:51 UTC
List:
ruby-core #63434
Issue #6806 has been updated by Alexey Muranov.
I meant that i function called like `Math::sin` would be required to return same values (for same arguments) every time. Maybe i did not explain this well. `Foo.bar`, on the other hand, would not have this restriction.
Same could be generalized to mutable (non-constant) objects, but there the distinction could be harder to make. Maybe `x::to_s` but `x.update!`?
----------------------------------------
Feature #6806: Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
https://bugs.ruby-lang.org/issues/6806#change-47477
* Author: Alexey Muranov
* Status: Feedback
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: Next Major
----------------------------------------
What would you say about this proposal? Is there a better alternative?
I suggest to support functional programming in Ruby by making module methods called with `ModuleName::method_name` syntax raise an exception if the method uses instance or class variables (instance variables of the singleton class, of course).
If i understand correctly, currently `ModuleName::method_name` and `ModuleName.method_name` behave identically, so i propose that they be different:
~~~ruby
module M
module_function
def f(x)
x*x
end
def g(x)
@x ||= x
@x*@x
end
end
M.f(2) # => 4
M.g(2) # => 4
M::f(3) # => 9
M::g(3) # => Error: instance variable `@x` used in a functional call `M::g`
~~~
Current behavior:
~~~ruby
M.f(2) # => 4
M.g(2) # => 4
M::f(3) # => 9
M::g(3) # => 4
~~~
--
https://bugs.ruby-lang.org/