Packages icon indicating copy to clipboard operation
Packages copied to clipboard

[Ruby]Add new `BlankSlate` snippet using `BasicObject`

Open toshimaru opened this issue 2 years ago • 11 comments

Description

Since Ruby 1.9, BasicObject is available to create BlankSlate class.

BasicObject is the parent class of all classes in Ruby. It's an explicit blank class.

BasicObject can be used for creating object hierarchies independent of Ruby's object hierarchy, proxy objects like the Delegator class, or other uses where namespace pollution from Ruby's methods and classes must be avoided.

ref. https://ruby-doc.org/core-1.9.3/BasicObject.html

I re-create BlankSlate snippet and modify tabTrigger in order to distinguish from other Ruby class snippets.

image

Changes

  • Use BasicObject for Ruby BlankSlate since BasicObject is available as of Ruby v1.9
  • Change tabTrigger from cla to clab since we already have some snippets triggered by cla
  • Simplify snippet file name

BlankSlate Example

The following is an example of BlankSlate class with BasicObject

class BlankSlate < BasicObject
end

toshimaru avatar Jun 05 '22 16:06 toshimaru

How about just not using that snippet?

Removed things tend to cause someone to complain for whatever reason. Just imagine maintainer of old code bases maybe relying on older ruby builds for some reason, which still might want that snippet.

deathaxe avatar Jun 08 '22 15:06 deathaxe

The linked page from above says that extended maintenance for v1.9.3 ended in 2015, so I guess he has a point.

jrappen avatar Jun 14 '22 13:06 jrappen

I have this Erlang conversation in mind when it comes to supporting legacy stuff. So if we don't remove keywords from a language, which have been deprecated since 2007, why should we remove things, which only date back to 2015?

The point is: There are probably dozens of out dated snippets like that. No one revized snippets for years. Removing one snippet doesn't change things nor does is it "much simpler". It's rather minor or even negligible.

deathaxe avatar Jun 14 '22 19:06 deathaxe

Right. I'm saying both your points are valid.

jrappen avatar Jun 14 '22 21:06 jrappen

@deathaxe thanks for your feedback :)

Removed things tend to cause someone to complain

Yes, that was my concern.

How about just not using that snippet?

I'm willing to do that, but I have another suggestion for this, what about adding another trigger for that because we already have a lot of snippet for cla.

image

I'd like to assign another trigger for BlankSlate class like Ruby methods (def + any char).

image

How about adding clab for the trigger? What do you think about my idea?

toshimaru avatar Jun 17 '22 05:06 toshimaru

Just in case you didn't know:

jrappen avatar Jun 17 '22 12:06 jrappen

That's good to know!

I'm lazy, so it'll be great if nice snippets are available by default rather than customizing. 😸

toshimaru avatar Jun 17 '22 13:06 toshimaru

How about adding clab for the trigger?

Looks like a reasonable change / trigger.

deathaxe avatar Jun 18 '22 22:06 deathaxe

@deathaxe Hey, I've re-added Ruby BlankSlate snippets. Could you review it ❓

toshimaru avatar Jun 20 '22 00:06 toshimaru

I hesitate approving this change because snippet's content is significantly changed. Changing trigger to reduce duplicates might be ok, but I am not sure whether changed content may cause complains.

deathaxe avatar Jun 24 '22 14:06 deathaxe

may cause complains.

I don't think so. BasicObject is available as of Ruby v1.9.3 and Ruby 1.9.3 EoL-ed on February 23, 2015.

I know many people are still using Ruby v2.x, but I don't know people still using Ruby v1.9 in 2023.

toshimaru avatar Jun 26 '22 02:06 toshimaru