U E D R , A S I H C RSS

Small Talk/문법정리

  • SBPP .


  • ~cpp ClassName>>methodName.
    • . 하, Smalltlak .
    • Debug .

  • ~cpp 
         
    UndifinedObject(Object)>>doesNotUnderstand:
    
  • :=
    ~cpp 
    a := 1.
    b := OrderedCollection new.
    
  • self :
    ~cpp 
    Money class>>amout: anAmount
        self new setAmount: anAmount.
    
  • super :
    ~cpp 
    TempTestCase>>initialize
        super initialize.
    
  • yourself : 해
    ~cpp 
    a := OrderdCollection new
        add: 10;
        add: 1;
        add; 9;
        yourself.
    
  • ^ : Smalltalk . C void . self .
    ~cpp 
    Color>>alpha
        ...
        ^1.0
    

from VisualWorks Lesson Browser 01 (Lesson: Language Basic)
  • 토크 표 .All Smalltalk expressions follow the form:
  • anObject aMessage.
  • )
    ~cpp 
    "Code in Bold"		"Comments in double-quotes"
    3 squared.		"Receiver object is small integer 3."
    			"The message sent is   #squared"
    
    'abc' asUppercase.	"Receiver object is string 'abc'."
    			"The message sent is   #asUppercase"
    
    200 factorial.		"Receiver object is small integer 200."
    			"The message sent is   #factorial"
    

from VisualWorks Lesson Browser 01 (Lesson: Language Basic)
  • Unary messages
    • , .(the selector is a single Identifier, there are no arguments)
    • )
      ~cpp 
      3 negated			"selector is  #negated"
      'abcdefg' reverse		"selector is  #reverse"
      
  • Binary messages
    • 호(하 , ), .(the selector is one or two non-alphanumeric characters, followed by exactly one argument object)
    • )
      ~cpp 
      3 + 5				"selector is  #+"
      				"argument is the Integer object 5"
      'abc' , 'xyz'			"selector is  #,  (comma character)"
      				"argument is the String 'xyz'"
      20 <= 20			"selector is  #<="
      				"argument is the Integer object 20"
      
  • Keyword messages
    • (:) .(a keyword is an Identifier followed by colon ":" )
    • , .(the selector is one or more keywords, when called each keyword is followed by an argument object) ->
    • )
      ~cpp 
      3 raisedTo: 17.			"selector is  #raisedTo:"
      				"argument is 17"
      3 between: 5 and: 10.		"selector is  #between:and:"
      				"arguments are 5 and 10"
      Point x: 4 y: 200. 		"receiver is the object Point"
      				"selector is  #x:y"
      				"arguments are 4 and 200"
      

2 + 3 * 6 ?
20 SmallTalk 30.--; .

토크 7 . extract method( ) .

팩토 .
as . .

Message

from Smalltalk by Example
  1. 행한. Evaluation is done left to right.
    • 2 + 3 * 6 -> 30
  2. Unary . messages have the highest precedence.
  3. Binary . Binary message have the next precedence.
  4. Keyword .Keyword message have the lowest precedence.
  5. 호 '()' . You can alter precedence by using parenthses.

Smalltalk
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:03
Processing time 0.0166 sec