From: patrick-may@... (Patrick May) Date: 2002-05-12T17:06:15+09:00 Subject: Re: cgi params api Wakou Aoyama wrote in message news:<20020511121152.GA29832%wakou@fsinet.or.jp>... > values = value.values # ??? > values = value.multiple # ... ... ok?? I feel like I like values better, since it emphasizes the plural more clearly. Either name sounds fine to me. > How about these things? > > > 1) Reduced impedance mismatch between Ruby and the protocol > > this means "cgi.name" api? cgi.name is not good.... other conflicts include: "type", "class", "id", "method", "display" It's not difficult for me to imagine situations where these would be the proper name for a form element. The more I list out the methods, the more I find things that will likely conflict somewhere. > > cgi.params.has_key?("name") # natural. > cgi.methods.include?(:name) # ...? This may be useful, I'm on the fence here. It might be nice from a coding perspective, I don't see it hurting. > > 2) Higher speed (Symbol being faster than String) I don't buy the performance justification.... + usually, I access a particular param once each time a cgi script runs. A speed up here wouldn't affect much. + implementation of this could easily add costs elsewhere. Maybe the parser would store every value twice, once under "name", once under :name. Maybe the cgi would convert strings to symbols or vice-versa when it looks up the value. Given my first point that a given param tends to be accessed once, neither of these really seem to be worth it. + the biggest cost in cgi scripts is the startup of the interpreter. building a clean library that integrates easily with mod_ruby, fastcgi, and other such enviroments would be a better investment of optimization energy. Once last note: Sean Chittenden wrote: > If you access reqs['key'], then you'll always get a non-array object. > reqs.get_array['key'] will return you an array like cgi.rb does > currently. I see value in seperating + pick this param, e.g. cgi["key"] + choose how to use it, e.g. value.values or value.multiple into separate decisions, in that order. ~ Patrick