Josh Cheek <josh.cheek / gmail.com> wrote:
> > [ ! should mark methods changing the receiver ]
> 
> I think it should become the convention. I consider the bang to be nearly
> meaningless as is.
> 
It is _normal_ in OO that objects change state, contrary to functional
languages. In functional languages any functions with side-effects are 
considered harmful (including print and puts).
In OO languages changing the state of an object is common:

a.name = "Peter"  # oh, this changes a, name= should end with !

data << item      # hm, data is changed, << should really have a !

e = mycoll.each   # lets get an enumerator
first = e.next    # this changes e, so should this be e.next! ?
                  # note: e is changed, mycoll is not

f = File.open("data") # open a file for reading
f.read(100)       # hm, this changes f, should this be f.read! ?
                  # note: f is changed, the file "data" is not.

class A
  attr_reader :x  # hm, attr_reader changes A, should have a !
end

Prawn::Document.generate('hello.pdf') do |pdf|
  pdf.text("Hello Prawn!")                          # this changes pdf
  pdf.canvas do
    pdf.line pdf.bounds.bottom_left, pdf.bounds.top_right  # this too!
  end
end 

and so on.

Klaus

-- 
http://lapiz.istik.de/

The Answer is 42. And I am the Answer. Now I am looking for the Question.