목 ¶
- SBPP를 공부기 문법 떼겠다는 각 들다.
기본 문법 ¶
~cpp ClassName>>methodName.
- 로 는 문법 다. 만, Smalltlak 명 당 메드가 디 발되는를 게 만들 다.
- Debug 모드 메 나낼때 된다.
- 로 는 문법 다. 만, Smalltlak 명 당 메드가 디 발되는를 게 만들 다.
~cpp 배때 가 보는 러 메 UndifinedObject(Object)>>doesNotUnderstand:
~cpp a := 1. b := OrderedCollection new.
~cpp Money class>>amout: anAmount self new setAmount: anAmount.
~cpp TempTestCase>>initialize super initialize.
~cpp a := OrderdCollection new add: 10; add: 1; add; 9; yourself.
~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"
- 는 단 며, 는 다.(the selector is a single Identifier, there are no arguments)
- 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"
- 는 기(나나 둘 문, 가 님)고, 가 나만 다.(the selector is one or two non-alphanumeric characters, followed by exactly one argument object)
- 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"
- 드란 론(:) 뒤 붙는 다.(a keyword is an Identifier followed by colon ":" )
기 ¶
2 + 3 * 6 몇까?
반로는 20겠만 SmallTalk는 30다.--; 라 기다.
되는데 몰 메드 길는 7 는다는 말 나다. 그러면 extract method( 말 로 만) 나다.
리링 관련 문구 나고 다.
리는 메드는 as를 붙다. 것 먹겠다.
리링 관련 문구 나고 다.
리는 메드는 as를 붙다. 것 먹겠다.
Message 달 ¶
from Smalltalk by Example
- 메는 른로 다. Evaluation is done left to right.
- 그래 2 + 3 * 6 -> 30
- 그래 2 + 3 * 6 -> 30
- Unary 메는 가 높 를 가다. messages have the highest precedence.
- Binary 메는 그 다 를 가다. Binary message have the next precedence.
- Keyword 메는 가 낮 를 가다.Keyword message have the lowest precedence.
- '()' 를 를 변경 다. You can alter precedence by using parenthses.
Smalltalk