[#3907] Obtaining mode information on an IO object — Jos Backus <jos@...>

The attached patch implements IO#mode. This method returns the mode the IO

17 messages 2004/12/06
[#3909] Re: [patch] Obtaining mode information on an IO object — nobu.nokada@... 2004/12/07

Hi,

[#3910] Re: [patch] Obtaining mode information on an IO object — Jos Backus <jos@...> 2004/12/07

On Tue, Dec 07, 2004 at 09:25:13AM +0900, nobu.nokada@softhome.net wrote:

[#3925] Re: [patch] Obtaining mode information on an IO object — James Britt <ruby@...> 2004/12/09

Jos Backus wrote:

[#4009] cgi.rb -- more GET/POST stuff — mde@...26.com

First of all, I think it would be great, as Eustaquio suggests, to

17 messages 2004/12/23
[#4016] Re: [PATCH] cgi.rb -- more GET/POST stuff — Francis Hwang <sera@...> 2004/12/24

GETs and POSTs are defined to be fairly different actions. I'd read

[#4027] Allowing custom number literal suffixes? — Florian Gro<florgro@...>

Moin!

35 messages 2004/12/27
[#4070] Re: Allowing custom number literal suffixes? — nobu.nokada@... 2005/01/02

Hi,

[#4072] Re: Allowing custom number literal suffixes? — Mathieu Bouchard <matju@...> 2005/01/02

[#4079] Re: Allowing custom number literal suffixes? — Florian Gro<florgro@...> 2005/01/03

Mathieu Bouchard wrote:

[#4081] Re: Allowing custom number literal suffixes? — Mathieu Bouchard <matju@...> 2005/01/03

[#4082] Re: Allowing custom number literal suffixes? — Florian Gro<florgro@...> 2005/01/03

Mathieu Bouchard wrote:

[#4084] Re: Allowing custom number literal suffixes? — Brent Roman <brent@...> 2005/01/04

I'm not sure I would advocate making Ruby's grammar even more

[#4086] Re: Allowing custom number literal suffixes? — Mathieu Bouchard <matju@...> 2005/01/04

[#4033] Garbage collection trouble — Christian Neukirchen <chneukirchen@...>

Hello,

13 messages 2004/12/27

Re: [patch] Obtaining mode information on an IO object

From: Jos Backus <jos@...>
Date: 2004-12-09 06:19:51 UTC
List: ruby-core #3933
On Thu, Dec 09, 2004 at 02:40:33PM +0900, James Britt wrote:
> >>Yes, it came from O_ACCMODE.
> >>cf. http://www.opengroup.org/onlinepubs/007908799/xsh/fcntl.h.html
> >>
> >>And ruby also has it.
> >> $ ruby -rfcntl -e 'p Fcntl::O_ACCMODE'
> >> 3
> >
> >
> >Hm, then again that in turn is a good argument for sticking with 
> >`accmode', as
> >it conforms to a known standard at least. Plus it's not too cryptic, is it?
> 
> Well, that's the question.  Who is the target audience, such that this 
> would be known, and what is gained from either name?
> 
> For those used to a certain sort of Unix C coding, many otherwise 
> cryptic names and commands are second nature, and carrying those names 
> over to a high level language conveys useful information.
 
Well, we are talking about a POSIX/OpenGroup interface here which as such is
standardized, and as Nobu points out has a precedent in terminology. As
Fcntl::O_ACCMODE is the official constant for the closely related file access
mode mask, I personally like its reflection in the name of the getter method,
`accmode'. But...

> On the other hand, there seems to be a general exhortation (certainly 
> something I've often seen mentioned among Rubyists) to write 
> self-documenting code and to use clear, descriptive names, rather than 
> terse abbreviations that save typing at the expense of long-term clarity.

I can clearly see this side of the argument as well. Then again, I'm not sure
if the term `access mode' is really clear to somebody who doesn't know the API
and would have to look it up anyhow.

> But see my first point; for the Unix-heads, "accmode" might be terribly 
> expressive.  For the rest of the world, people who code in Ruby unless 
> there is a compelling reason to drop down to C, "accmode" is probably 
> too terse.
 
Note: this is not necessarily about Unix/C but about programming against the
OpenGroup platform API, which brings with it certain nomenclature and defined
terms as part of the standardization effort.

> "access_mode" should be clear enough to both camps, unless there is 
> something about it's behavior that is tied to some special quality of 
> the Unix variant, or is likely something only to be of interest to those 
> accustomed to a certain low-level coding.
> 
> But maybe it's me; I still find myself writing, for example, [].unique, 
> only to be reminded that, in RubyWorld, 'unique' has a, um, uniq spelling.

Heh. Another idiom that traces its roots back to Unix; depending on one's
background this can be seen as either qt or obfuscating. I bet you won't
forget this method's peculiar name because of it though :)

Perhaps `accmode' and `access_mode' can be aliases? That would make these two
camps happy but perhaps upset a third party.

Cheers,
-- 
Jos Backus                       _/  _/_/_/      Sunnyvale, CA
                                _/  _/   _/
                               _/  _/_/_/
                          _/  _/  _/    _/
jos at catnook.com        _/_/   _/_/_/          require 'std/disclaimer'

In This Thread