Comments on Programming Scalaurn:uuid:660d7d6a-ac6b-373b-8d86-ce73a6d5bc1d2009-08-11T20:58:30-07:00 <div>Visibility Rules <p id="para_when_you_compile_this_file_wit">When you compile this file with <strong class="userinput"><code>scalac</code></strong>, you get the following output. (The file name before the <code class="literal">N:</code> line numbers have been removed from the output to better fit the space.)</p> <blockquote><p>in: def equalFields(other: ProtectedClass1) = (protectedField1 == other.protectedField1) &amp;&amp; (protectedField1 == other.protectedField1) &amp;&amp; (nested == other.nested) there is a typing error should be def equalFields(other: ProtectedClass1) = (protectedField1 == other.protectedField1) &amp;&amp; (protectedField2 == other.protectedField2) &amp;&amp; (nested == other.nested) </p> &#8212; shalom (2009-08-04 21:44:06) </blockquote> </div>urn:uuid:d695636f-8e7c-3bbe-8f55-b18308461c8dshalom2009-08-04T21:44:06-07:00Comment on 'Visibility Rules' <div>Visibility Rules <p id="para_let_s_begin_by_considering_the">Let&#8217;s begin by considering the only differences in behavior between scoped private and scoped public, how they behave under inheritance when members have these scopes.</p> <blockquote><blockquote><blockquote><p>Let’s begin by considering the only differences in behavior between scoped private and scoped public </p> </blockquote></blockquote><p>Probably meant </p> <p>Let’s begin by considering the only differences in behavior between scoped private and scoped protected </p> &#8212; maddalab (2009-08-02 05:18:35) </blockquote> </div>urn:uuid:29978c2f-f1f6-3613-b4ff-496c5e70d313maddalab2009-08-02T05:18:35-07:00Comment on 'Visibility Rules' <div>Visibility Rules <p id="para_visibility_scopes_table_summarizes_the_visibility_scopes"><a class="xref" href="ch05.html#visibility-scopes-table" title="Table&#160;5.1.&#160;Visibility Scopes.">Table&#160;5.1, &#8220;Visibility Scopes.&#8221;</a> summarizes the visibility scopes.</p> <blockquote><p>wouldn't this suffice, in the note </p> <pre> <p>class Restricted[A] private (name: String) {…} </p> </pre> <p>especially since you have not yet mentioned variance and type parameters. </p> &#8212; maddalab (2009-08-02 04:41:25) </blockquote> </div>urn:uuid:0ba121bd-f916-317a-9585-9bf8f88a0cf8maddalab2009-08-02T04:41:25-07:00Comment on 'Visibility Rules' <div>Constructors in Scala <p id="para_the_primary_constructor_for_r">The primary constructor for <code class="literal">RadioButtonWithCallbacks</code> takes three parameters: an <code class="literal">on</code> state (<code class="literal">true</code> or <code class="literal">false</code>), a label, and a list of callbacks. It passes the label and list of callbacks to its parent class, <code class="literal">ButtonWithCallbacks</code>. The <code class="literal">on</code> parameter is declared as a <code class="literal">var</code>, so it is mutable. <code class="literal">on</code> is also the one constructor parameter unique to a radio button, so it is kept as an attribute of <code class="literal">RadioButtonWithCallbacks</code>.</p> <blockquote><pre> class RadioButtonWithCallbacks( var on: Boolean, label: String, clickedCallbacks: List[() => Unit]) extends ButtonWithCallbacks(label, clickedCallbacks) </pre> What happened the the val keywords before label and clickedCallbacks. I figured out why they are not used, however they reason deserves a mention &#8212; maddalab (2009-08-01 17:30:31) </blockquote> </div>urn:uuid:b7f7a1a5-4670-3f80-b481-68d9cb4e8267maddalab2009-08-01T17:30:31-07:00Comment on 'Constructors in Scala' <div>Constructors in Scala <p id="para_for_consistency_with_its_paren">For consistency with its parent class, <code class="literal">RadioButtonWithCallbacks</code> also declares two auxiliary constructors. Note that they must invoke a preceding constructor in <code class="literal">RadioButtonWithCallbacks</code>, as before. They can&#8217;t invoke a <code class="literal">ButtonWithCallbacks</code> constructor directly. Declaring all these constructors in each class could get tedious after a while, but we explored techniques in <a class="xref" href="ch04.html" title="Chapter&#160;4.&#160;Traits">Chapter&#160;4, <i>Traits</i></a> that can eliminate repetition.</p> <blockquote><p>This presumably also means that a given subclass may only invoke one of the parent class's constructors. Compare that to, for instance, Java exception hierarchies, where there tends to be a parallel hierarchy of constructors. </p> &#8212; diathesis (2009-07-14 10:32:51) </blockquote> </div>urn:uuid:5a5ae23b-13e5-35ff-b5b5-7d03297b522fdiathesis2009-07-14T10:32:51-07:00Comment on 'Constructors in Scala' <div>Parent Classes <p id="para_scala_supports__single_inherit">Scala supports single inheritance, not multiple inheritance. A child (or derived) class can have one and only one parent (or base) class. The sole exception is the root of the Scala class hierarchy, <code class="literal">Any</code>, which has no parent.</p> <blockquote><p>I was just wondering why the 'Any' class was allowed to have more than one parent class, 'til I read these comments. </p> &#8212; diathesis (2009-07-14 10:22:16) </blockquote> </div>urn:uuid:666864ee-2e5e-3e62-b043-0dd894ab1330diathesis2009-07-14T10:22:16-07:00Comment on 'Parent Classes' <div>Visibility Rules <div class="table" id="visibility-scopes-table"><p class="title"><b>Table&#160;5.1.&#160;Visibility Scopes.</b></p><div class="table-contents"><table summary="Visibility Scopes." border="0"><colgroup><col align="left" /><col align="left" /><col align="left" /></colgroup><thead valign="top"><tr><th align="left" valign="top"> Name </th><th align="left" valign="top"> Keyword </th><th align="left" valign="top"> Description</th></tr></thead><tbody valign="top"><tr><td align="left" valign="top"><p>public</p></td><td align="left" valign="top"><p><span class="emphasis"><em>none</em></span></p></td><td align="left" valign="top"><p>Public members and types are visible everywhere, across all boundaries.</p></td></tr><tr><td align="left" valign="top"><p>protected</p></td><td align="left" valign="top"><p><code class="literal">protected</code></p></td><td align="left" valign="top"><p>Protected members are visible to the defining type, to derived types, and to nested types. Protected types are visible only within the same package and subpackages.</p></td></tr><tr><td align="left" valign="top"><p>private</p></td><td align="left" valign="top"><p><code class="literal">private</code></p></td><td align="left" valign="top"><p>Private members are visible only within the defining type and nested types. Private types are visible only within the same package.</p></td></tr><tr><td align="left" valign="top"><p>scoped protected</p></td><td align="left" valign="top"><p><code class="literal">protected[scope]</code></p></td><td align="left" valign="top"><p>Visibility is limited to <code class="literal">scope</code>, which can be a package, type, or <code class="literal">this</code> (meaning the same instance, when applied to members, or the enclosing package, when applied to types). See the text below for details.</p></td></tr><tr><td align="left" valign="top"><p>scoped private</p></td><td align="left" valign="top"><p><code class="literal">private[scope]</code></p></td><td align="left" valign="top"><p>Synonymous with scoped protected visibility, except under inheritance (discussed below).</p></td></tr></tbody></table></div></div> <blockquote><p>@Alexander: no, that's not possible. @Mario: true. thanks. will fix. </p> &#8212; deanwampler (2009-07-12 21:40:08) </blockquote> </div>urn:uuid:d52e297a-b72d-3c4f-9b84-51a0f8adb7bfdeanwampler2009-07-12T21:40:08-07:00Comment on 'Visibility Rules' <div>Constructors in Scala <p id="para_the_following_example_illustra">The primary constructor in a derived class must invoke one of the parent class constructors, either the primary constructor or an auxiliary constructor. In the following example, a class derived from <code class="literal">ButtonWithCallbacks</code>, called <code class="literal">RadioButtonWithCallbacks</code>, invokes the primary <code class="literal">ButtonWithCallbacks</code> constructor. &#8220;Radio&#8221; buttons can be either on or off.</p> <blockquote><p>Limited by the print format. </p> &#8212; deanwampler (2009-07-12 21:38:17) </blockquote> </div>urn:uuid:72feb9ee-ab30-39e9-bf92-273605e3a3f3deanwampler2009-07-12T21:38:17-07:00Comment on 'Constructors in Scala' <div>Constructors in Scala <p id="para_if_a_parameter_has_the_var_k">If a parameter has the <code class="literal">var</code> keyword, a public writer method is also generated with the parameter&#8217;s name as a prefix, followed by <code class="literal">_=</code>. For example, if <code class="literal">label</code> were declared as a <code class="literal">var</code>, the writer method would be named <code class="literal">label_=</code> and it would take a single argument of type <code class="literal">String</code>.</p> <blockquote><p>True. Will clarify. </p> &#8212; deanwampler (2009-07-12 21:29:22) </blockquote> </div>urn:uuid:69d03d8d-d35d-3f1d-b61d-fd05619b03d8deanwampler2009-07-12T21:29:22-07:00Comment on 'Constructors in Scala' <div>Constructors in Scala <p id="para__buttonwithcallbacks_defines_"><code class="literal">ButtonWithCallbacks</code> defines three constructors. The primary constructor, which is the body of the entire class, has a parameter list that takes a label string and a list of callback functions. Because each parameter is declared as a <code class="literal">val</code>, the compiler generates a private field corresponding to each parameter (a different internal name is used), along with a public reader method that has the same name as the parameter. &#8220;Private&#8221; and &#8220;public&#8221; have the same meaning here as in most object-oriented languages. We&#8217;ll discuss the various visibility rules and the keywords that control them in <a class="xref" href="ch05.html#VisibilityRules" title="Visibility Rules">the section called &#8220;Visibility Rules&#8221;</a> below.</p> <blockquote><p>We'll describe this later. </p> &#8212; deanwampler (2009-07-12 21:29:12) </blockquote> </div>urn:uuid:339d8ec7-269c-370e-8651-3a66236ccd8bdeanwampler2009-07-12T21:29:12-07:00Comment on 'Constructors in Scala' <div>Parent Classes <p id="para_as_in_java_the_keyword_exten">As in Java, the keyword <code class="literal">extends</code> indicates the parent class, in this case <code class="literal">BulkReader</code>. In Scala, <code class="literal">extends</code> is also used when a class inherits a trait as its parent (even when it mixes in other traits using the <code class="literal">with</code> keyword). Also, <code class="literal">extends</code> is used when one trait is the child of another trait or class. Yes, traits can inherit classes.</p> <blockquote><p>Thanks. will clarify. </p> &#8212; deanwampler (2009-07-12 21:17:32) </blockquote> </div>urn:uuid:1f480291-59d2-37c3-838e-7f2aa14263a5deanwampler2009-07-12T21:17:32-07:00Comment on 'Parent Classes' <div>Parent Classes <p id="para_scala_supports__single_inherit">Scala supports single inheritance, not multiple inheritance. A child (or derived) class can have one and only one parent (or base) class. The sole exception is the root of the Scala class hierarchy, <code class="literal">Any</code>, which has no parent.</p> <blockquote><p>Thanks. will consider this rewording. </p> &#8212; deanwampler (2009-07-12 21:16:28) </blockquote> </div>urn:uuid:ea074680-9452-348b-8585-8a1be1d545d5deanwampler2009-07-12T21:16:28-07:00Comment on 'Parent Classes' <div>Constructors in Scala <p id="para_if_a_parameter_has_the_var_k">If a parameter has the <code class="literal">var</code> keyword, a public writer method is also generated with the parameter&#8217;s name as a prefix, followed by <code class="literal">_=</code>. For example, if <code class="literal">label</code> were declared as a <code class="literal">var</code>, the writer method would be named <code class="literal">label_=</code> and it would take a single argument of type <code class="literal">String</code>.</p> <blockquote><p>It should be specified what happens when you don't use neither val nor val. </p> &#8212; bieffe (2009-07-10 07:46:23) </blockquote> </div>urn:uuid:7f360379-c9ca-3818-88e0-b321507fd761bieffe2009-07-10T07:46:23-07:00Comment on 'Constructors in Scala' <div>Visibility Rules <p id="para_scala_s_visibility_rules_are_s">Scala&#8217;s visibility rules are similar to Java&#8217;s, but tend to be both more consistently applied and more flexible. For example, in Java, if an inner class has a <code class="literal">private</code> member, the enclosing class can see it. In Scala, the enclosing class can&#8217;t see a <code class="literal">private</code> member, but Scala provides another way to declare it visible to the enclosing class.</p> <blockquote><p>Thanks. Added this to the table below. </p> &#8212; deanwampler (2009-07-03 14:33:45) </blockquote> </div>urn:uuid:a0ca746d-7cfe-3fd1-9335-45cb9acf1720deanwampler2009-07-03T14:33:45-07:00Comment on 'Visibility Rules' <div>Visibility Rules <div class="table" id="visibility-scopes-table"><p class="title"><b>Table&#160;5.1.&#160;Visibility Scopes.</b></p><div class="table-contents"><table summary="Visibility Scopes." border="0"><colgroup><col align="left" /><col align="left" /><col align="left" /></colgroup><thead valign="top"><tr><th align="left" valign="top"> Name </th><th align="left" valign="top"> Keyword </th><th align="left" valign="top"> Description</th></tr></thead><tbody valign="top"><tr><td align="left" valign="top"><p>public</p></td><td align="left" valign="top"><p><span class="emphasis"><em>none</em></span></p></td><td align="left" valign="top"><p>Public members and types are visible everywhere, across all boundaries.</p></td></tr><tr><td align="left" valign="top"><p>protected</p></td><td align="left" valign="top"><p><code class="literal">protected</code></p></td><td align="left" valign="top"><p>Protected members are visible to the defining type, to derived types, and to nested types. Protected types are visible only within the same package and subpackages.</p></td></tr><tr><td align="left" valign="top"><p>private</p></td><td align="left" valign="top"><p><code class="literal">private</code></p></td><td align="left" valign="top"><p>Private members are visible only within the defining type and nested types. Private types are visible only within the same package.</p></td></tr><tr><td align="left" valign="top"><p>scoped protected</p></td><td align="left" valign="top"><p><code class="literal">protected[scope]</code></p></td><td align="left" valign="top"><p>Visibility is limited to <code class="literal">scope</code>, which can be a package, type, or <code class="literal">this</code> (meaning the same instance, when applied to members, or the enclosing package, when applied to types). See the text below for details.</p></td></tr><tr><td align="left" valign="top"><p>scoped private</p></td><td align="left" valign="top"><p><code class="literal">private[scope]</code></p></td><td align="left" valign="top"><p>Synonymous with scoped protected visibility, except under inheritance (discussed below).</p></td></tr></tbody></table></div></div> <blockquote><p>Protected types are also visible within the sub packages. </p> &#8212; magle (2009-06-28 04:03:03) </blockquote> </div>urn:uuid:f60d4d95-04c5-3a07-824b-771904c7e1aamagle2009-06-28T04:03:03-07:00Comment on 'Visibility Rules' <div>Constructors in Scala <p id="para__buttonwithcallbacks_defines_"><code class="literal">ButtonWithCallbacks</code> defines three constructors. The primary constructor, which is the body of the entire class, has a parameter list that takes a label string and a list of callback functions. Because each parameter is declared as a <code class="literal">val</code>, the compiler generates a private field corresponding to each parameter (a different internal name is used), along with a public reader method that has the same name as the parameter. &#8220;Private&#8221; and &#8220;public&#8221; have the same meaning here as in most object-oriented languages. We&#8217;ll discuss the various visibility rules and the keywords that control them in <a class="xref" href="ch05.html#VisibilityRules" title="Visibility Rules">the section called &#8220;Visibility Rules&#8221;</a> below.</p> <blockquote><p>You can also see, that you always firstly have to call the primary or another auxiliary constructor when defining an auxiliary constructor. </p> &#8212; magle (2009-06-25 16:32:57) </blockquote> </div>urn:uuid:a0b07070-146d-3a9d-92a7-13f61d8cf7d1magle2009-06-25T16:32:57-07:00Comment on 'Constructors in Scala' <div>Parent Classes <p id="para_as_in_java_the_keyword_exten">As in Java, the keyword <code class="literal">extends</code> indicates the parent class, in this case <code class="literal">BulkReader</code>. In Scala, <code class="literal">extends</code> is also used when a class inherits a trait as its parent (even when it mixes in other traits using the <code class="literal">with</code> keyword). Also, <code class="literal">extends</code> is used when one trait is the child of another trait or class. Yes, traits can inherit classes.</p> <blockquote><p>Keyword extends does not explicitly / always indicate the parent class. It is also used to mix in a trait (in case a class implicitly / only inherits from Any) </p> &#8212; magle (2009-06-25 16:03:44) </blockquote> </div>urn:uuid:beb5c54d-1393-361c-b97e-ded6ea3a6522magle2009-06-25T16:03:44-07:00Comment on 'Parent Classes' <div>Constructors in Scala <p id="para_in_order_to_avoid_potential_in">In order to avoid infinite recursion, Scala requires each auxiliary constructor to invoke another constructor defined before it <a class="xref" href="apa.html#ScalaSpec2009">[ScalaSpec2009]</a>. The constructor invoked may be either another auxiliary constructor or the primary constructor, and it must be the first statement in the auxiliary constructor&#8217;s body. Additional processing can occur after this call, such as the warning message printed in our example.</p> <blockquote><p>another constructors &lt;- </p> &#8212; robcd (2009-06-21 08:33:11) </blockquote> </div>urn:uuid:243b3d31-b7c9-3644-b49f-b64925270b0arobcd2009-06-21T08:33:11-07:00Comment on 'Constructors in Scala' <div>Visibility Rules <p id="para_let_s_explore_these_visibility">Let&#8217;s explore these visibility options in more detail. To keep things simple, we&#8217;ll use fields for member examples. Method and <code class="literal">type</code> declarations behave the same way.</p> <blockquote><p>The note below is good! The 'non apologizing' for the missing but useful feature of being able to set visibility for packages is IMHo much better than the varieties of "we didn't need that feature often" often found in books about various programming languages. </p> &#8212; battisti (2009-06-14 14:38:10) </blockquote> </div>urn:uuid:6ae62f88-fa33-3385-bfca-fefd45d51f3abattisti2009-06-14T14:38:10-07:00Comment on 'Visibility Rules' <div>Visibility Rules <div class="table" id="visibility-scopes-table"><p class="title"><b>Table&#160;5.1.&#160;Visibility Scopes.</b></p><div class="table-contents"><table summary="Visibility Scopes." border="0"><colgroup><col align="left" /><col align="left" /><col align="left" /></colgroup><thead valign="top"><tr><th align="left" valign="top"> Name </th><th align="left" valign="top"> Keyword </th><th align="left" valign="top"> Description</th></tr></thead><tbody valign="top"><tr><td align="left" valign="top"><p>public</p></td><td align="left" valign="top"><p><span class="emphasis"><em>none</em></span></p></td><td align="left" valign="top"><p>Public members and types are visible everywhere, across all boundaries.</p></td></tr><tr><td align="left" valign="top"><p>protected</p></td><td align="left" valign="top"><p><code class="literal">protected</code></p></td><td align="left" valign="top"><p>Protected members are visible to the defining type, to derived types, and to nested types. Protected types are visible only within the same package and subpackages.</p></td></tr><tr><td align="left" valign="top"><p>private</p></td><td align="left" valign="top"><p><code class="literal">private</code></p></td><td align="left" valign="top"><p>Private members are visible only within the defining type and nested types. Private types are visible only within the same package.</p></td></tr><tr><td align="left" valign="top"><p>scoped protected</p></td><td align="left" valign="top"><p><code class="literal">protected[scope]</code></p></td><td align="left" valign="top"><p>Visibility is limited to <code class="literal">scope</code>, which can be a package, type, or <code class="literal">this</code> (meaning the same instance, when applied to members, or the enclosing package, when applied to types). See the text below for details.</p></td></tr><tr><td align="left" valign="top"><p>scoped private</p></td><td align="left" valign="top"><p><code class="literal">private[scope]</code></p></td><td align="left" valign="top"><p>Synonymous with scoped protected visibility, except under inheritance (discussed below).</p></td></tr></tbody></table></div></div> <blockquote><p>"Private members are visible only within the defining type. Private types are visible only within the same package." Is it possible to define a single type across multiple packages? </p> &#8212; battisti (2009-06-14 14:33:53) </blockquote> </div>urn:uuid:b85b22fb-2d9a-33a7-9aac-ccf17d44521abattisti2009-06-14T14:33:53-07:00Comment on 'Visibility Rules' <div>Visibility Rules <p id="para_scala_s_visibility_rules_are_s">Scala&#8217;s visibility rules are similar to Java&#8217;s, but tend to be both more consistently applied and more flexible. For example, in Java, if an inner class has a <code class="literal">private</code> member, the enclosing class can see it. In Scala, the enclosing class can&#8217;t see a <code class="literal">private</code> member, but Scala provides another way to declare it visible to the enclosing class.</p> <blockquote><p>You could also mention here, that an inner class can access private members of it's outer/enclosing class. </p> &#8212; battisti (2009-06-14 14:31:46) </blockquote> </div>urn:uuid:57d2688d-0bc8-38cf-833b-60b90cb2c870battisti2009-06-14T14:31:46-07:00Comment on 'Visibility Rules' <div>Constructors in Scala <p id="para_for_consistency_with_its_paren">For consistency with its parent class, <code class="literal">RadioButtonWithCallbacks</code> also declares two auxiliary constructors. Note that they must invoke a preceding constructor in <code class="literal">RadioButtonWithCallbacks</code>, as before. They can&#8217;t invoke a <code class="literal">ButtonWithCallbacks</code> constructor directly. Declaring all these constructors in each class could get tedious after a while, but we explored techniques in <a class="xref" href="ch04.html" title="Chapter&#160;4.&#160;Traits">Chapter&#160;4, <i>Traits</i></a> that can eliminate repetition.</p> <blockquote><p>You should drive the point, that only the primary constructor is able (and has to) call the superclasses constructor, more clearly. Maybe even directly at the beginning of the "Calling Parent Class Constructors" section. </p> &#8212; battisti (2009-06-14 14:25:19) </blockquote> </div>urn:uuid:31a0a8fe-b1ef-3c5f-9017-5e89801eafadbattisti2009-06-14T14:25:19-07:00Comment on 'Constructors in Scala' <div>Constructors in Scala <p id="para_the_following_example_illustra">The primary constructor in a derived class must invoke one of the parent class constructors, either the primary constructor or an auxiliary constructor. In the following example, a class derived from <code class="literal">ButtonWithCallbacks</code>, called <code class="literal">RadioButtonWithCallbacks</code>, invokes the primary <code class="literal">ButtonWithCallbacks</code> constructor. &#8220;Radio&#8221; buttons can be either on or off.</p> <blockquote><p>Creating a dedicated example with shorter names to avoid the line breaks would be nice. It is really hard to find the call to the superclasses primary constructor after this bunch of this relatively complicated type declarations - which are not helpful at all for understanding the currently described concept. Especially if you don't show the definition of the ButtonWithCallbacks class (to allow the reader to see for him/herself which constructor of the parent class is called) </p> &#8212; battisti (2009-06-14 14:21:11) </blockquote> </div>urn:uuid:476eee4c-68dd-343e-af4b-f71da4884eebbattisti2009-06-14T14:21:11-07:00Comment on 'Constructors in Scala' <div>Constructors in Scala <dt id="varlistentry-less-flexibility"><span class="term"> Less Flexibility </span></dt> <blockquote><p>"However, the authors find these circumstances to be rare." sounds a lot like the: "In practice type errors don't happen much." Mantra found in books about 'dynamic languages' vs. the "Static type checking is really useful." found in books about 'static languages'. The readers should know for themselves how often they found a particular language feature useful or not. You shouldn't anchor them. </p> <p>Simply mentioning that Scala doesn't have this feature, hinting that use might be an indicator for violating the 'single responsibility principle' should be enough. </p> &#8212; battisti (2009-06-14 14:14:39) </blockquote> </div>urn:uuid:fcf625ba-86b2-386e-b37b-d5942c26f4e1battisti2009-06-14T14:14:39-07:00Comment on 'Constructors in Scala' <div>Parent Classes <p id="para_scala_supports__single_inherit">Scala supports single inheritance, not multiple inheritance. A child (or derived) class can have one and only one parent (or base) class. The sole exception is the root of the Scala class hierarchy, <code class="literal">Any</code>, which has no parent.</p> <blockquote><p>Instead of "A child (or derived) class can have one and only one parent (or base) class.", "All classes have exactly one parent class." would be a more concise 'lead in' to the next sentence: "The sole exception is the root..." </p> &#8212; battisti (2009-06-14 13:54:05) </blockquote> </div>urn:uuid:8089da96-b560-3bd4-9de0-cdd99517f126battisti2009-06-14T13:54:05-07:00Comment on 'Parent Classes' <div>Visibility Rules <p id="para_the_only_errors_are_when_we_at">The only errors are when we attempt to access members scoped to <code class="literal">scopeA</code> from the unrelated package <code class="literal">scopeB</code> and when we attempt to access a member from a nested package <code class="literal">scopeA2</code> that is scoped to that package.</p> <blockquote><p>Thanks again for the catch. </p> &#8212; deanwampler (2009-06-08 19:20:30) </blockquote> </div>urn:uuid:73df7fed-a230-3f24-ae27-b6932fc85541deanwampler2009-06-08T19:20:30-07:00Comment on 'Visibility Rules' <div>Visibility Rules <p id="para_hence_when_applied_to_types_">Hence, when applied to types, <code class="literal">private[this]</code> is equivalent to Java&#8217;s <code class="literal">package private</code> visibility.</p> <blockquote><p>Thanks! </p> &#8212; deanwampler (2009-06-08 19:19:47) </blockquote> </div>urn:uuid:903c0669-00b5-344c-868a-3095710e7c56deanwampler2009-06-08T19:19:47-07:00Comment on 'Visibility Rules' <div>Class and Object Basics <p id="para_like_java_but_unlike_ruby_sc">Like Java, but unlike Ruby and Python, Scala allows <span class="emphasis"><em>overloaded methods</em></span>. Two or more methods can have the same name as long as their full <span class="emphasis"><em>signatures</em></span> are unique. The <span class="emphasis"><em>signature</em></span> includes the type name, the list of parameters with types, and the method&#8217;s return value.</p> <blockquote><p>Henrik, very true. Will add text for it. Thanks. Jason, very helpful example. Thanks. We discuss the namespace issue later. I'll include links to those areas. </p> &#8212; deanwampler (2009-06-08 18:49:29) </blockquote> </div>urn:uuid:b1b7d4f0-b4f5-3cd9-ac8e-3728b934b415deanwampler2009-06-08T18:49:29-07:00Comment on 'Class and Object Basics' <div>Visibility Rules <p id="para_the_only_errors_are_when_we_at">The only errors are when we attempt to access members scoped to <code class="literal">scopeA</code> from the unrelated package <code class="literal">scopeB</code> and when we attempt to access a member from a nested package <code class="literal">scopeA2</code> that is scoped to that package.</p> <blockquote><p>s/package/private/ (below) </p> &#8212; retronym (2009-05-20 05:30:14) </blockquote> </div>urn:uuid:87c5e98b-0a3a-384b-9a52-bcee96fa6f52retronym2009-05-20T05:30:14-07:00Comment on 'Visibility Rules' <div>Visibility Rules <p id="para_hence_when_applied_to_types_">Hence, when applied to types, <code class="literal">private[this]</code> is equivalent to Java&#8217;s <code class="literal">package private</code> visibility.</p> <blockquote><p>s/package/private/ </p> &#8212; retronym (2009-05-20 05:29:53) </blockquote> </div>urn:uuid:b265c729-fc91-3f9a-8e36-4e231d3f30f2retronym2009-05-20T05:29:53-07:00Comment on 'Visibility Rules'