* [ruby-core:46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
@ 2012-07-28 13:26 alexeymuranov (Alexey Muranov)
2012-07-28 13:37 ` [ruby-core:46830] [ruby-trunk - Feature #6806] " alexeymuranov (Alexey Muranov)
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: alexeymuranov (Alexey Muranov) @ 2012-07-28 13:26 UTC (permalink / raw
To: ruby-core
Issue #6806 has been reported by alexeymuranov (Alexey Muranov).
----------------------------------------
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
Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version:
=begin
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:
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:
M.f(2) # => 4
M.g(2) # => 4
M::f(3) # => 9
M::g(3) # => 4
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:46830] [ruby-trunk - Feature #6806] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
2012-07-28 13:26 [ruby-core:46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name alexeymuranov (Alexey Muranov)
@ 2012-07-28 13:37 ` alexeymuranov (Alexey Muranov)
2012-07-30 19:32 ` [ruby-core:46876] " drbrain (Eric Hodel)
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: alexeymuranov (Alexey Muranov) @ 2012-07-28 13:37 UTC (permalink / raw
To: ruby-core
Issue #6806 has been updated by alexeymuranov (Alexey Muranov).
I think that if you say a new person that `M::f` and `M.f` are the same in Ruby, they won't believe at first. So why keeping them the same?
----------------------------------------
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-28507
Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version:
=begin
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:
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:
M.f(2) # => 4
M.g(2) # => 4
M::f(3) # => 9
M::g(3) # => 4
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:46876] [ruby-trunk - Feature #6806] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
2012-07-28 13:26 [ruby-core:46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name alexeymuranov (Alexey Muranov)
2012-07-28 13:37 ` [ruby-core:46830] [ruby-trunk - Feature #6806] " alexeymuranov (Alexey Muranov)
@ 2012-07-30 19:32 ` drbrain (Eric Hodel)
2014-06-30 13:31 ` [ruby-core:63432] " alexey.muranov
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: drbrain (Eric Hodel) @ 2012-07-30 19:32 UTC (permalink / raw
To: ruby-core
Issue #6806 has been updated by drbrain (Eric Hodel).
Assignee set to matz (Yukihiro Matsumoto)
Target version set to 3.0
This would break compatibility with much ruby code.
----------------------------------------
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-28551
Author: alexeymuranov (Alexey Muranov)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 3.0
=begin
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:
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:
M.f(2) # => 4
M.g(2) # => 4
M::f(3) # => 9
M::g(3) # => 4
=end
--
http://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:63432] [ruby-trunk - Feature #6806] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
2012-07-28 13:26 [ruby-core:46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name alexeymuranov (Alexey Muranov)
2012-07-28 13:37 ` [ruby-core:46830] [ruby-trunk - Feature #6806] " alexeymuranov (Alexey Muranov)
2012-07-30 19:32 ` [ruby-core:46876] " drbrain (Eric Hodel)
@ 2014-06-30 13:31 ` alexey.muranov
2014-06-30 13:37 ` [ruby-core:63433] [ruby-trunk - Feature #6806] [Feedback] " nobu
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: alexey.muranov @ 2014-06-30 13:31 UTC (permalink / raw
To: ruby-core
Issue #6806 has been updated by Alexey Muranov.
Besides functional programming, IMO this would support [command–query separation](https://en.wikipedia.org/wiki/Command–query_separation).
----------------------------------------
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-47475
* Author: Alexey Muranov
* Status: Open
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: Next Major
----------------------------------------
=begin
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:
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:
M.f(2) # => 4
M.g(2) # => 4
M::f(3) # => 9
M::g(3) # => 4
=end
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:63433] [ruby-trunk - Feature #6806] [Feedback] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
2012-07-28 13:26 [ruby-core:46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name alexeymuranov (Alexey Muranov)
` (2 preceding siblings ...)
2014-06-30 13:31 ` [ruby-core:63432] " alexey.muranov
@ 2014-06-30 13:37 ` nobu
2014-06-30 13:45 ` [ruby-core:63434] [ruby-trunk - Feature #6806] " alexey.muranov
2014-06-30 14:02 ` [ruby-core:63435] " nobu
5 siblings, 0 replies; 7+ messages in thread
From: nobu @ 2014-06-30 13:37 UTC (permalink / raw
To: ruby-core
Issue #6806 has been updated by Nobuyoshi Nakada.
Description updated
Status changed from Open to Feedback
It seems unrelated to "functional programming" at all.
----------------------------------------
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-47476
* 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/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:63434] [ruby-trunk - Feature #6806] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
2012-07-28 13:26 [ruby-core:46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name alexeymuranov (Alexey Muranov)
` (3 preceding siblings ...)
2014-06-30 13:37 ` [ruby-core:63433] [ruby-trunk - Feature #6806] [Feedback] " nobu
@ 2014-06-30 13:45 ` alexey.muranov
2014-06-30 14:02 ` [ruby-core:63435] " nobu
5 siblings, 0 replies; 7+ messages in thread
From: alexey.muranov @ 2014-06-30 13:45 UTC (permalink / raw
To: ruby-core
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/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:63435] [ruby-trunk - Feature #6806] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name
2012-07-28 13:26 [ruby-core:46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name alexeymuranov (Alexey Muranov)
` (4 preceding siblings ...)
2014-06-30 13:45 ` [ruby-core:63434] [ruby-trunk - Feature #6806] " alexey.muranov
@ 2014-06-30 14:02 ` nobu
5 siblings, 0 replies; 7+ messages in thread
From: nobu @ 2014-06-30 14:02 UTC (permalink / raw
To: ruby-core
Issue #6806 has been updated by Nobuyoshi Nakada.
It's just your style.
I use `Math.sin` and so on.
----------------------------------------
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-47478
* 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/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-06-30 13:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-28 13:26 [ruby-core:46829] [ruby-trunk - Feature #6806][Open] Support functional programming: forbid instance/class variables for ModuleName::method_name, allow for ModuleName.method_name alexeymuranov (Alexey Muranov)
2012-07-28 13:37 ` [ruby-core:46830] [ruby-trunk - Feature #6806] " alexeymuranov (Alexey Muranov)
2012-07-30 19:32 ` [ruby-core:46876] " drbrain (Eric Hodel)
2014-06-30 13:31 ` [ruby-core:63432] " alexey.muranov
2014-06-30 13:37 ` [ruby-core:63433] [ruby-trunk - Feature #6806] [Feedback] " nobu
2014-06-30 13:45 ` [ruby-core:63434] [ruby-trunk - Feature #6806] " alexey.muranov
2014-06-30 14:02 ` [ruby-core:63435] " nobu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).