Project

General

Profile

Actions

Feature #8807

open

Custom literals

Feature #8807: Custom literals

Added by trans (Thomas Sawyer) about 12 years ago. Updated almost 5 years ago.

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

Description

So why can't we define custom literals? There's been recent discussion about adding a new freeze literal. Would have been nice if coders could have defined it for themselves, then it would have been more clear if there really was enough use to add it to core.

I imagine the syntax of such a feature to be quite simple.

def %foo(string, mod=nil)
p [string, mod]
end

%foo{something}o
=> ["something", "o"]

Updated by drbrain (Eric Hodel) about 12 years ago Actions #1 [ruby-core:56776]

If you define a new literal in file "a.rb" you cannot use it in that file that defined it as it has already been parsed. This may be confusing.

Updated by Anonymous about 12 years ago Actions #2 [ruby-core:56972]

-1

Updated by naruse (Yui NARUSE) about 12 years ago Actions #3 [ruby-core:57532]

  • Target version changed from 2.1.0 to 3.0

Updated by naruse (Yui NARUSE) almost 5 years ago Actions #4

  • Target version deleted (3.0)
Actions

Also available in: PDF Atom