< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #6507 has been reported by trans (Thomas Sawyer).
----------------------------------------
Feature #6507: File Literal
https://bugs.ruby-lang.org/issues/6507
Author: trans (Thomas Sawyer)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: 2.0.0
=begin
One of the features of the Rebol programming language that I has always liked is its direct support for files via the (({%filename})) notation (See http://www.rebol.com/r3/docs/datatypes/file.html). I've often wondered how Ruby might support the same, but finding a suitable and available notation proved rather difficult.
Today it occurred to me that perhaps the `/` symbol could do the trick:
file = /README.rdoc
For absolute paths it could be `//`:
file = //etc/fstab
Exactly what class of object (({file})) should be is up for debate. Probably it would be a (({Pathname})) instance, but I suppose it could a different "Path" class basically a wrapper round (({File})) and (({Dir})) classes.
The benefit of this is fairly obvious I think, but I'll give one clear usecase just the same:
class Foo
def initialize(source)
case source
when String
parse(source)
when Pathname # assuming this to be the instance
parse(source.read)
end
end
end
# from string
Foo.new "content of foo"
# from file
Foo.new /foo.txt
There is the ambiguity of `x /a` for division, but I think expecting `x/a` or `x / a` for that is okay. After all, the same limitation holds for other unary operators too.
Actually, while I like the concise notation, it may be more flexible to require a string:
/'foo.txt'
Then `/` could actually be a unary operator.
In anycase, whether this notation works or not, I hope this spurs some debate so that ultimately something along these lines will come of it. I truly tire of typing things like (({File.read(File.join(File.dirname(__FILE__), fname))})).
=end
--
http://bugs.ruby-lang.org/