Project

General

Profile

Actions

Feature #16347

open

InmutableObject

Added by dvarrui (David Vargas) about 5 years ago. Updated almost 3 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:95841]

Description

I notice Ruby is OOP language but also includes Functional programming features. But it's no 100% FP.
I like OOP, and Ruby but I think its good idea adding more features to our Ruby... always with respect at ruby wat. (Fun for developers)

================
INMUTABLE OBJECT

I know every Class inherits from Object and then inherits from BasicObject.
So I wonder if it could be posible create InmutableObject so... every class descending from InmutableObject... its also force to be Inmutable.
Perhaps with this option... it could be posible to be 100% FP and 100% OOP.

Could I do something more about this theme?

Thanks for your attention!

Updated by Hanmac (Hans Mackowiak) about 5 years ago

i don't think "Functional Programming" works the way you think in ruby.

in Ruby everything is an Object so it is always OOP, even your FP is just fake with OOP

to make an object not changeable you might freeze it after you created it. (or even deep freeze it for all the attributes and instance variables too?)

for Immutable + Ruby i found this:
https://www.rubypigeon.com/posts/a-review-of-immutability-in-ruby/

Updated by dvarrui (David Vargas) about 5 years ago

Thanks!
Good document.

I didnt know deep_freeze. Its nice!

Updated by dvarrui (David Vargas) about 5 years ago

dvarrui (David Vargas) wrote:

Thanks!
Good document.

I didnt know deep_freeze. Its nice!

Actions #4

Updated by hsbt (Hiroshi SHIBATA) almost 3 years ago

  • Project changed from 14 to Ruby master
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0