[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Minor Change Proposal for Classes 'Object' and 'Method'

WoNáDo

1/19/2007 4:15:00 PM

Minor Change Proposal for Classes 'Object' and 'Method'
_______________________________________________________


I would like to make a small change suggestion on the class 'Method' by which
the method 'Object#method' is also affected.

Background:
___________

When creating a 'Method' object, it is not possible to receive the object
identification of the object which uses the 'Object#method' method (see 'Example
for Workaround' for details) by using some Method of class 'Method'.

It is useful for some applications to analyse later on which to which objects a
method is bound in an object of class 'Method'. In addition, it is simply
missing from my viewpoint, because it is an essential information (attribute) of
an object of class 'Method'.

A minor wish is an additional method for class 'Method', which returns the
contents of 'Method#to_s' as an Array containing two elements, the class-name
and the method-name without the textual border of 'Method#to_s'. It is easier
and less expensive to return this existing information by a method of class
'Method', than to use a regular expression later on to extract the information.

The method names used by here are only suggestions, since I needed names for the
example. Regarding definite names I have no emotions.

___________


>>>>> Example for Workaround >>>>>
class Object
alias :_org_method :method
def method(name)
method_object = self._org_method(name)
method_object.instance_id = self.object_id
method_object
end
end

class Method
attr_accessor :instance_id
def method_name
md = self.to_s.match(/Method:\s*([^#]+)#([^>]+)>/)
return md[1], md[2]
end
end

# Now an example

class Hugo
def hi
puts "An instance of Hugo says 'Hi!'"
end
end

my_hugo = Hugo.new
puts my_hugo.object_id # => 22497820 (for example)
myhi = my_hugo.method(:hi)
myhi[] # => An instance of Hugo says 'Hi!'
puts myhi.instance_id # => 22497820 (for example)
p myhi.method_name # => ["Hugo", "hi"]
>>>>> End of Example >>>>>

___________


Please inform me, if this is not the right place for a change proposal.

Wolfgang Nádasi-Donner (WoNáDo)
6 Answers

WoNáDo

1/26/2007 4:21:00 PM

0

I don't know where to put this message into the very large discussion tree, so I
will put it here.

There is an argument against naming a method "receiver", which returns the
object which was bound to a method object.

>>>>> Example >>>>>

class Otto
def hi
puts "'Hi!' from an 'Otto' instance (#{self.inspect})"
end
end

class Hugo < Otto
def hi
puts "'Hi!' from an 'Hugo' instance (#{self.inspect})"
end
end

o = Otto.new
h = Hugo.new
bo = o.method(:hi)
bh = bo.unbind.bind(h)

h.hi # => 'Hi!' from an 'Hugo' instance (#<Hugo:0x2aea4dc>)
bh.call # => 'Hi!' from an 'Otto' instance (#<Hugo:0x2aea4dc>)
bo.call # => 'Hi!' from an 'Otto' instance (#<Otto:0x2aea478>)

>>>>> EoE >>>>>

In this example, the "Method" object "bh" contains (I temporary use this wording
for this example) the object "h", and the method "Otto#hi", which can be seen
in the output of "bh.call" - but - if ones sends the message "hi" to the object
"h" the method "Hugo#hi" will be used (see output for "h.hi").

This means, that for the object "h" contained in "Method" object "bh" a message
"hi" will not end up in calling "Otto#hi", because it finds "Hugo#hi".

It is misleading to call "h" the "receiver" of a message, that leads to the
invocation of "Otto#hi", because this cannot be done by any message in this example.

May be a different name is better to avoid confusion.

Wolfgang Nádasi-Donner

WoNáDo

1/26/2007 4:34:00 PM

0

Sorry, I didn't recognize, that this was already named. More than 90 posts in
this discussion are very much...

Wolfgang Nádasi-Donner

WoNáDo

1/30/2007 10:24:00 AM

0

Hi!

I don't know how you handle "Change Proposals" for Ruby. Implement them silently
or write somewhere an announcement, so I try to summarize what happens, as I
understood it.

Please correct me if I'm wrong, because I will report about the results in the
german Ruby forum.

I include my proposal for class "UnboundMethod" here, because I think it is
strongly related to this one.

----------------------------

As I understood, the will be some new methods available now or in the near
future in the repository (or the nightly snapshot). I'm not sure about the
chosen names, so please correct them.

==============
Class "Method"
==============

Public instance Methods:

receiver
--------
"receiver" returns the bound object of the method object. E.g. for "mo =
o.method(:m)" the expression "mo.receiver" will return "o".

name
----
"name" returns the name of the method object. E.g. for "mo = o.method(:m)" the
expression "mo.name" will return ":m" (symbol) or "'m'" (string).

owner
-----
"owner" returns the class which holds the method. E.g. for "mo = o.method(:m)"
the expression "mo.owner" will return "c", if the method ":m", that is bound to
"mo", is defined in this class. If the class is an anonymous class, it will be
handled correctly.

=====================
Class "UnboundMethod"
=====================

Public instance Methods:

name
----
"name" returns the name of the method object. E.g. for "mo = o.method(:m)" the
expression "mo.name" will return ":m" (symbol) or "'m'" (string).

owner
-----
"owner" returns the class which holds the method. E.g. for "mo = o.method(:m)"
the expression "mo.owner" will return "c", if the method ":m", that is bound to
"mo", is defined in this class. If the class is an anonymous class, it will be
handled correctly.

-----------------------

Is it a correct summary. There are so many messages in the discussion, that I
ended up in comfusion about the chosen names, sorry.

Wolfgang Nádasi-Donner

THE BORG

3/20/2010 5:20:00 AM

0

When the Great God Shiva opens his Third Eye he will destroy
the Universe.


Kadaitcha Man

3/20/2010 5:57:00 AM

0

"Christopher A. Lee", thou swag-bellied jealous rascally knave. A pox
damn you, you muddy rascal, is that all the comfort you bring me. Ye
guffawed:

> On Fri, 19 Mar 2010 17:30:19 -0700 (PDT), BURT <macromitch@yahoo.com>
> wrote:
>
>>God does not need to prove that He exists.
>
> Where is anybody demanding it do that, imbecile?

Right here...

> Do you honestly not understand we are telling believers to either put up
> or shut up?

The irony escapes you, hey.

--
I have defined no god. And when I do need to define some god for the
purposes of discussing its nature with atheists I always define the
supposed some god in the very same concrete and arbitrary terms, without
variation:

God = Metaphysical X

Watching you idiot atheists witlessly pinning your own lunatic
assumptions and irrational perceptions onto it then attempting to argue
against your very own deranged Frankenstein-like creation with utterly
b0rked illogic is a never-ending source of great hilarity.

Kadaitcha Man

3/20/2010 7:54:00 AM

0

"PepsiFreak@teranews.com", thou musty coward and coistrel. Despised
substance of divinest show. Ye wallowed:

> "Kadaitcha Man" <anon@no.email> wrote in message
> news:2mf91d$b50$2@sucking-libertine.com.kuwait...
>> "Olrik", thou jarring foolish. Nothing but lechery, ye incontinent
>> varlet. Ye screamed:
>>
>>> Le 2010-03-19 20:30, BURT a ??crit :
>>
>>>> God does not need to prove that He exists.
>>>
>>> Yes, it does.
>>
>> No, 'it' does not. Knowledge of truth beyond proof is superior to
>> idiotic demands for proof of the unprovable.
>
> If it is unprovable, it is not truth - asshole!

BWAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA!

Truth, you gobsmacked, shallow-minded, mentally-ill atheist fool, outruns
provability.

Logical Proof - Truth Outruns Provability
+=======================================+
Purpose: To prove that truth outruns provability

Definitions:

Computable: Capable of being computed, numbered, or reckoned.
Note: The definition of computable does not imply machine
computation. The mind is capable of performing
such computations and can apply rules (axioms)
to those computations independently of a machine.

Provable: Capable of being proved; Capable of being established as
truth.

Truth: Conformity to fact or reality; exact accordance with
that which is, or has been; or shall be. Conformity to
rule; exactness.

Proof
=====
Given a computably generated set of axioms, let PROVABLE be the set of
numbers which encode sentences which are provable from the given axioms.

Thus for any sentence s,

(1) <s> is in PROVABLE iff s is provable.
Since the set of axioms is computably generable,
so is the set of proofs which use these axioms and
so is the set of provable theorems and hence
so is PROVABLE, the set of encodings of provable theorems.
Since computable implies definable in adequate theories, PROVABLE
is definable.
Let s be the sentence "This sentence is false".
By Tarski, s exists since it is the solution of:
(2) s iff <s> is not in PROVABLE.
Thus
(3) s iff <s> is not in PROVABLE iff s is not provable.
Now (excluded middle) s is either true or false.
If s is false, then by (3), s is provable.
This is impossible since provable sentences are true.
Thus s is true.
Thus by (3), s is not provable.
Hence s is true but unprovable.

Conclusion: There are statements that are true but cannot be proved.
Corollary: Truth outruns provability.

Instead of wasting what little brain-power you have arguing, just tick
your preferred idiotic atheistic objections (logical fallacies) under the
appropriate categories below:

Ad hoc assertions:
(pathetic evasions go here)

Additional ad hominem:
(call theists rude names here)

Red herring:
(Assert something irrelevant here)

Straw man:
(Totally misrepresent an argument and demand that someone
refute your misrepresentation here)

Affirmations of the consequent:
(A implies B, B is true, so A is true.)

Argumentum ad Septicus:
(Assert that "there is no God" is not an assertion
See Appendix B for etymology)

Amphibolies:
(spurious ambiguity due to lack of grammatical coherency)

Argumentum ad baculum:
(You'll kick my head in and screw my wife)

Anecdotal fallacies:
(A lack of evidence proves there is no God)

Argumentum ad ignorantiam:
(Theism is a lie, everybody knows that)

Argumentum ad misericordiam:
(Appeal to pity, the Syd M., Jimbo and Uncle Vic school of thought)
"If God cares about his creations he should be willing to
learn about our needs and wants."
"he will ignore me like he ignores the cries of agony from
his creations every day."

Shift the burden of proof:
(Assert that you are not mentally ill and demand
additional proof that you are, for example.)

Argumentum ad nauseam:
make your assertions here that atheism is not a
mental illness. The more times you repeat it, the more
likely you'll believe it)

Argumentum ad numerum:
("No atheist will buy this shit" assertions go here)

Hypostatisation:
(You can't show me that God exists therefore God does not
exist assertions go here)

Argumentum ad populum:
(Appeal to other atheists for support here)

Argumentum ad verecundiam:
(Insert names of famous atheists here. Also assert that
you are a scientist and have a higher IQ therefore you are
not mentally ill here. Also see Appendix C)

Bifurcation:
(It's highly unlikely that you were created. Science seems to
tell you that you came out of a primordial slime due to random
chance and chemicals, and you'd rather believe a scientist, Mary
Baker-Eddy for example)

Complex question and fallacy of presupposition:
(So, have you stopped belting your wife yet?)

Hasty generalisations:
(Assert a part of theism to be false (without backup
argument) then ascribe falsity to the whole of theism)

Denial of the antecedent:
(You've never met God and if God existed, He'd have let you
know, therefore God does not exist)

Sweeping generalisation:
(Solve the world's moral problems here by asserting
your own rules)

Fallacy of division:
(I am an idiot, therefore all theists are idiots)
(All theists are idiots, therefore I am an idiot)

Tu quoque:
(IKYABWAI Lames go here... Assertions that theism is
a mental illness, for example)

Ignoratio elenchi:
(Assert an irrelevant conclusion that has nothing at
all to do with you being mentally ill)

Argumentum ad logicam:
(Argue that atheism is not a mental illness because
it's the conclusion of a fallacious argument)

Non sequitur:
(Assert a conclusion not logically connected to any
premise here, assert that the universe was farted
out of a giant badger, for example)

Plurium interrogationum:
(Ask a complex question and demand a simple answer here)

No true atheist fallacy:
(no true atheist would buy this crap type assertions
here, please)

Non causa pro causa:
(blame something else for your mental illness here
without showing how that something else is the cause)

London to a bucket of your mashed brains says you can't fart and chew gum
at the same time without passing out from excessive brain exertion.

--
I have defined no god. And when I do need to define some god for the
purposes of discussing its nature with atheists I always define the
supposed some god in the very same concrete and arbitrary terms, without
variation:

God = Metaphysical X

Watching you idiot atheists witlessly pinning your own lunatic
assumptions and irrational perceptions onto it then attempting to argue
against your very own deranged Frankenstein-like creation with utterly
b0rked illogic is a never-ending source of great hilarity.