Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Self (programming language)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Basic syntax === The syntax for accessing slots is similar to that of Smalltalk. Three kinds of messages are available: ;unary : <code>''receiver'' slot_name</code> ;binary : <code>''receiver'' + ''argument''</code> ;keyword : <code>''receiver'' keyword: ''arg1'' With: ''arg2''</code> All messages return results, so the receiver (if present) and arguments can be themselves the result of other messages. Following a message by a period means Self will discard the returned value. For example: <syntaxhighlight lang="smalltalk">'Hello, World!' print.</syntaxhighlight> This is the Self version of the [["Hello, World!" program]]. The <code>'</code> syntax indicates a literal string object. Other literals include numbers, blocks and general objects. Grouping can be forced by using parentheses. In the absence of explicit grouping, the unary messages are considered to have the highest precedence followed by binary (grouping left to right) and the keywords having the lowest. The use of keywords for assignment would lead to some extra parenthesis where expressions also had keyword messages, so to avoid that Self requires that the first part of a keyword message selector start with a lowercase letter, and subsequent parts start with an uppercase letter. <syntaxhighlight lang="smalltalk">valid: base bottom between: ligature bottom + height And: base top / scale factor.</syntaxhighlight> can be parsed unambiguously, and means the same as: <syntaxhighlight lang="smalltalk">valid: ((base bottom) between: ((ligature bottom) + height) And: ((base top) / (scale factor))).</syntaxhighlight> In Smalltalk-80, the same expression would be written as: <syntaxhighlight lang="smalltalk">valid := self base bottom between: self ligature bottom + self height and: self base top / self scale factor.</syntaxhighlight> assuming <code>base</code>, <code>ligature</code>, <code>height</code> and <code>scale</code> were not [[instance variable]]s of <code>self</code> but were, in fact, methods.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Self (programming language)
(section)
Add topic