Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Vererbung
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joachim Hofmann  
View profile   Translate to Translated (View Original)
 More options Jul 15 2011, 6:58 am
Newsgroups: de.comp.lang.ruby
From: Joachim Hofmann <joachim.hofm...@toptarif.de>
Date: Fri, 15 Jul 2011 12:58:57 +0200
Local: Fri, Jul 15 2011 6:58 am
Subject: Vererbung
Hallo,

was bedeutet genau die Symbolik <  und  ::  in einem Ausdruck wie:

   class CreateVehicles << ActiveRecord::Migration

dass es "Vererbung" bedeutet, ist mir mehr oder weniger klar, nur was
ist der Unterschied von  <  und  ::
?

Danke

Joachim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Krahnke  
View profile   Translate to Translated (View Original)
 More options Jul 15 2011, 5:07 pm
Newsgroups: de.comp.lang.ruby
From: Simon Krahnke <overl...@gmx.li>
Date: Fri, 15 Jul 2011 23:07:19 +0200
Local: Fri, Jul 15 2011 5:07 pm
Subject: Re: Vererbung
* Joachim Hofmann <joachim.hofm...@toptarif.de> (12:58) schrieb:

> Hallo,

> was bedeutet genau die Symbolik <  und  ::  in einem Ausdruck wie:

>   class CreateVehicles << ActiveRecord::Migration

> dass es "Vererbung" bedeutet, ist mir mehr oder weniger klar,

Das "<<" in der Klassendefinition bedeutet, das der Name der Superklasse folgt.

> nur was ist der Unterschied von  <  und  :: ?

"::" hat damit nichts zu tun. In dem Modul "Activerecord" findet sich eine
Konstante "Migration", die eine Klasse als Wert hat.

mfg,                     simon .... l


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Klemme  
View profile   Translate to Translated (View Original)
 More options Jul 16 2011, 8:41 am
Newsgroups: de.comp.lang.ruby
From: Robert Klemme <shortcut...@googlemail.com>
Date: Sat, 16 Jul 2011 14:41:18 +0200
Local: Sat, Jul 16 2011 8:41 am
Subject: Re: Vererbung
On 15.07.2011 23:07, Simon Krahnke wrote:

> * Joachim Hofmann<joachim.hofm...@toptarif.de>  (12:58) schrieb:

>> was bedeutet genau die Symbolik<   und  ::  in einem Ausdruck wie:

>>    class CreateVehicles<<  ActiveRecord::Migration

>> dass es "Vererbung" bedeutet, ist mir mehr oder weniger klar,

> Das "<<" in der Klassendefinition bedeutet, das der Name der Superklasse folgt.

Nur, dass es nicht "<<" sondern "<" ist.

$ ruby19 -ce 'class X << String;end'
-e:1: syntax error, unexpected tLSHFT, expecting '<' or ';' or '\n'
class X << String;end
           ^

>> nur was ist der Unterschied von<   und  :: ?

> "::" hat damit nichts zu tun. In dem Modul "Activerecord" findet sich eine
> Konstante "Migration", die eine Klasse als Wert hat.

Ich würde es "Scope-" oder "Namespace Operator" nennen.

Ciao

        robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Krahnke  
View profile   Translate to Translated (View Original)
 More options Jul 16 2011, 5:19 pm
Newsgroups: de.comp.lang.ruby
From: Simon Krahnke <overl...@gmx.li>
Date: Sat, 16 Jul 2011 23:19:36 +0200
Local: Sat, Jul 16 2011 5:19 pm
Subject: Re: Vererbung
* Robert Klemme <shortcut...@googlemail.com> (14:41) schrieb:

Tja, "<<" machte aber auch irgendwas. Lua, wieder C, nun D, da soll ich
noch Ruby können? Außerdem, Vererbung, bäh! Obwohl, hab ich in meinem
Raytracer glaube ich benutzt. Warum auch immer, braucht man wegen
Ducktyping eh nicht.

>>> nur was ist der Unterschied von<   und  :: ?

>> "::" hat damit nichts zu tun. In dem Modul "Activerecord" findet sich eine
>> Konstante "Migration", die eine Klasse als Wert hat.

> Ich würde es "Scope-" oder "Namespace Operator" nennen.

Mir war sowieso nie klar, wo der Unterschied zu "." liegt.

mfg,                      simon .... l


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jörg W Mittag  
View profile   Translate to Translated (View Original)
 More options Jul 17 2011, 7:47 am
Newsgroups: de.comp.lang.ruby
From: Jörg W Mittag <JoergWMittag+R...@GoogleMail.Com>
Date: Sun, 17 Jul 2011 13:47:28 +0200
Local: Sun, Jul 17 2011 7:47 am
Subject: Re: Vererbung

Simon Krahnke wrote:
> * Robert Klemme <shortcut...@googlemail.com> (14:41) schrieb:
>> On 15.07.2011 23:07, Simon Krahnke wrote:
>>> * Joachim Hofmann<joachim.hofm...@toptarif.de>  (12:58) schrieb:
>>>> nur was ist der Unterschied von<   und  :: ?
>>> "::" hat damit nichts zu tun. In dem Modul "Activerecord" findet sich eine
>>> Konstante "Migration", die eine Klasse als Wert hat.
>> Ich würde es "Scope-" oder "Namespace Operator" nennen.
> Mir war sowieso nie klar, wo der Unterschied zu "." liegt.

    module M
      def self.Test; 'Method'   end
      Test =         'Constant'
    end

    M::Test   # => 'Constant'
    M.Test    # => 'Method'
    M::Test() # => 'Method'

Ob das ein *sinnvoller* Unterschied ist, das ist eine ganz andere
Frage ;-)

Meiner Meinung nach haben Konstanten und Variablen in einer
objekt-orientierten Sprache nichts zu suchen. Newspeak ist ein
Beispiel, das schön zeigt, wie eine Sprache nicht nur massiv einfacher
sondern gleichzeitig deutlich mächtiger und ausdrucksstärker wird,
wenn man Konstanten, Variablen, Felder etc. abschafft.

Zum Beispiel gibt es Mixins quasi geschenkt, man braucht sie nicht als
spezielles Sprachfeature wie in Ruby. Ebenso bekommt man ein
Modulsystem, virtuelle Klassen, Klassenhierarchie-Vererbung und noch
einiges anderes, alles ohne irgendeine Art von Sprachunterstützung
einfach nur durch die Objektorientierung.

jwm


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Krahnke  
View profile   Translate to Translated (View Original)
 More options Jul 17 2011, 2:19 pm
Newsgroups: de.comp.lang.ruby
From: Simon Krahnke <overl...@gmx.li>
Date: Sun, 17 Jul 2011 20:19:47 +0200
Local: Sun, Jul 17 2011 2:19 pm
Subject: Re: Vererbung
* Jörg W Mittag <JoergWMittag+R...@GoogleMail.Com> (13:47) schrieb:

Ah ja, für eine Methode nimmt also ".", für eine Konstante (wie ein
Modul oder eine Klasse) nimmt man "::".

> Ob das ein *sinnvoller* Unterschied ist, das ist eine ganz andere
> Frage ;-)

Das es von dem was man haben will abhängt, ist wohl eine Konsequenz
davon, überhaupt zwei Listen von Elementen zu haben.

mfg,                       simon .... l


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jörg W Mittag  
View profile   Translate to Translated (View Original)
 More options Jul 18 2011, 11:55 am
Newsgroups: de.comp.lang.ruby
From: Jörg W Mittag <JoergWMittag+R...@GoogleMail.Com>
Date: Mon, 18 Jul 2011 17:55:08 +0200
Local: Mon, Jul 18 2011 11:55 am
Subject: Re: Vererbung

Ja, das ist die Konvention. Muss man aber nicht:

    def (o = Object.new).test; 'Did somebody call me?' end
    o::test # => 'Did somebody call me?'

Der Namensraum-Operator '::' lässt sich praktisch überall anstatt des
Nachrichtensendungsoperators '.' verwenden (aber natürlich nicht
umgekehrt), *außer* für argumentlose Nachrichten, die mit einem
Großbuchstaben anfangen:

     module M
       def self.Test; 'Method'   end
     end

     M.Test    # => 'Method'
     M::Test() # => 'Method'

aber:

     M::Test   # NameError: uninitialized constant M::Test

jwm


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joachim Hofmann  
View profile   Translate to Translated (View Original)
 More options Jul 19 2011, 4:34 am
Newsgroups: de.comp.lang.ruby
From: Joachim Hofmann <joachim.hofm...@toptarif.de>
Date: Tue, 19 Jul 2011 10:34:25 +0200
Local: Tues, Jul 19 2011 4:34 am
Subject: Re: Vererbung
On 15.07.2011 23:07, Simon Krahnke wrote:

> * Joachim Hofmann<joachim.hofm...@toptarif.de>  (12:58) schrieb:

>>    class CreateVehicles<<  ActiveRecord::Migration

> Das "<<" in der Klassendefinition bedeutet, das der Name der Superklasse folgt.

>> nur was ist der Unterschied von<   und  :: ?

> "::" hat damit nichts zu tun. In dem Modul "Activerecord" findet sich eine
> Konstante "Migration", die eine Klasse als Wert hat.

Ich nehme mal an, dass ich das verstehe, so wie ich OOP fr her gelernt
habe, dann aber: Warum gebe ich also so eine Konstante hier explizit an?
Habe ich doch durch die Vererbung sowieso auch in der Unterklasse
Zugriff auf diese Klassenkonstante?

Gru Joachim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Krahnke  
View profile   Translate to Translated (View Original)
 More options Jul 19 2011, 6:16 am
Newsgroups: de.comp.lang.ruby
From: Simon Krahnke <overl...@gmx.li>
Date: Tue, 19 Jul 2011 12:16:15 +0200
Local: Tues, Jul 19 2011 6:16 am
Subject: Re: Vererbung
* Joachim Hofmann <joachim.hofm...@toptarif.de> (10:34) schrieb:

Wie bitte? Klassen sind Ruby Objekte. Um sie wiederzufinden speichert
man sie in Konstanten.

Nat rlich kennt jede Klasse ihre Superklasse, aber wenn das eine andere
als Object sein soll, muss man das Ruby schon mitteilen, in dem man bei
der Definition mit "<" auf sie verweist.

Dabei wei die generierte Klasse doch nicht, das die Superklasse der
Wert einer Konstante ist.

mfg,                simon .... l


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »