I’m not quite following. Do you mean this specifically in relation
to the design of cgi.rb?
Sorry, I should have been clearer. The original issue that was mentioned
(assuming I didn’t come into the thread too late) was that if one does
something like:
require ‘cgi’
include CGI::Html3
this makes the module-level method available without specying the “namespace”,
so that you can do things like:
puts html { h1 { “Hello, world!” } }
but that then the DOCTYPE specification doesn’t end up in the output.
Instead, one sees something like
Hello, world!
I thought people were saying the reason for this was that the DOCTYPE stuff
only happens if one constructs a new CGI instance in the code.
What I meant was that if the construction of that object has the side-effect
of setting up some infrastructure, then that infrastructure could,
potentially be set up as top-level code.
As I say, I’ve never tried this in a module, but have done it in classes quite
a few times. For example, …
class Fred
@@REPOSITORY = “Fred.saved”
@@freds = []
if FileTest.exists? @@REPOSITORY
File.open(@@REPOSITORY) do |file|
@@freds = Marshal.load(file.readlines)
end
end
def initialize
# ...
end
# ...
end
Ie, by doing this stuff at the class level, it happens automagically, making
it transparent to the user of the class.
I’m just suggesting that perhaps this is something the CGI library could be
doing, if the setup of the DOCTYPE is something that is always wanted.
Maybe I’ve completely missed the point of the discussion, though … not
unprecedented :-).