| class | protocol | namespace |
---|
ABAP Objects | '''class''' name '''definition''' «'''inheriting from''' parentclass»'''.''' «'''interfaces:''' interfaces'''.'''» method_and_field_declarations '''endclass.'''<br />'''class''' name '''implementation.''' method_implementations '''endclass.''' | '''interface''' name'''.''' members '''endinterface.''' | |
APL (Dyalog) | ''':Class''' name «''':'''parentclass» «''','''interfaces»
members
''':EndClass''' | ''':Interface''' name
members
''':EndInterface''' | ''':Namespace''' name
members
''':EndNamespace''' |
C++ | '''class '''name«''' : public '''parentclasses [7] »''' { '''members''' };''' | | '''namespace '''name''' { '''members''' }''' |
C# | '''class '''name«''' : '''«parentclass»«''',''' interfaces»»''' { '''members''' }''' | '''interface''' name« ''':''' parentinterfaces» '''{''' members '''}''' |
D | '''module '''name''';''' <br /> members |
eC | '''class''' name« ''':''' base class» '''{''' «default member values assignments» «members» '''}''' |
| '''namespace''' name; |
Java | '''class '''name«''' extends '''parentclass»«''' implements '''interfaces»''' { '''members''' }''' | '''interface''' name« '''extends''' parentinterfaces» '''{''' members '''}''' | '''package '''name''';''' members |
PHP | '''namespace '''name'''; '''members |
Objective-C | '''@interface '''name«''' : '''parentclass» [8] «'''<''' protocols '''>'''»''' { '''instance_fields''' } '''method_and_property_declarations''' @end <br /> @implementation '''name method_implementations''' @end''' [9] | '''@protocol '''name«'''<''' parentprotocols '''>'''» members''' @end''' | |
Swift | '''class '''name«''' : '''«parentclass»«''',''' protocols»»''' { '''members''' }''' | '''protocol '''name«''' : '''parentprotocols»''' { '''members''' }''' | |
Python | '''class '''name«'''('''parentclasses<ref name="multi" />''')'''»''':<br />{{keypress|Tab}} '''members | [10] | '''__all__ = [ '''member1''','''member2''',... ]''' |
Visual Basic .NET | '''Class '''name«''' Inherits '''parentclass»«''' Implements '''interfaces»<br />members <br />'''End Class''' | '''Interface '''name«''' Inherits '''parentinterfaces»<br />members <br />'''End Interface''' | '''Namespace '''name<br />members <br />'''End Namespace''' |
Xojo | '''Class '''name«''' Inherits '''parentclass»«''' Implements '''interfaces»<br />members <br />'''End Class''' | '''Interface '''name«''' Inherits '''parentinterfaces»<br />members <br />'''End Interface''' | '''Module '''name<br />members <br />'''End Module''' |
Eiffel | '''class '''name«''' inherit '''parentclasses<ref name="multi" />»<br />members<br />'''end''' | colspan=2 |
Perl | '''package '''name'''; '''«'''@ISA = qw('''parentclasses<ref name="multi" />''');'''» members '''1;''' | | '''package '''name''';''' members |
Raku | '''class '''name «'''is''' parentclass «'''is''' parentclass ...<ref name="multi" />»» «'''does''' role «'''does''' role ...»» '''{''' members '''}''' | '''role '''name «'''does''' role «'''does''' role ...»» '''{''' members '''}''' | '''module''' name '''{''' members '''}''' |
Ruby | '''class '''name« '''<''' parentclass» <br /> members <br /> '''end''' | | '''module '''name <br /> members <br /> '''end''' |
Windows PowerShell | colspan=3 |
OCaml | '''class '''name «parameters»''' = object '''«'''(self)'''» «'''inherit '''parentclass «parameters» «'''inherit '''parentclass «parameters» ...<ref name="multi" />»» members '''end''' | | '''module''' name <br /> members |
F# | '''type '''name«'''('''parameters''')'''»''' '''«'''as this'''» '''= class''' «'''inherit '''parentclass«'''('''parameters''')'''» «'''as base'''»» members «'''interface''' interface '''with''' implementation «'''interface''' interface '''with''' implementation ...»» '''end''' | '''type '''name '''= interface''' members '''end''' | '''namespace''' name <br /> members |
Smalltalk | [11] | | [12] |
JavaScript (ES6) | class name «'''extends''' parentclass» '''{''' members '''}''' | | |
Object Pascal (Delphi) | '''ClassName = Class''' «('''ClassParent, Interfaces)'''»
private
// Private members(include Methods and Fields)
public
// Public members
protected
// Protected members
published
// Published members
end; | | '''package '''name''';''' members |
Scala | class ConcreteClass(constructor params)extends ParentClasswith Trait1 with Trait2 with Trait2 | trait TraitNameextends OtherTrait1with OtherTrait2 with OtherTrait3 | package name |
COBOL | '''CLASS-ID.''' name« '''INHERITS'''« '''FROM'''» parentclasses»'''.''' '''FACTORY'''« '''IMPLEMENTS''' interfaces»'''.'''
'''OBJECT'''« '''IMPLEMENTS''' interfaces»'''.'''
'''END CLASS''' name'''.''' | '''INTERFACE-ID.''' name« '''INHERITS'''« '''FROM'''» interfaces»'''.''' '''END INTERFACE''' name'''.''' | |
Cobra | '''class''' name «'''inherits''' parentclass» «'''implements''' interfaces»<br />{{keypress|Tab}} members | '''interface''' name «'''inherits''' parentinterfaces»<br />{{keypress|Tab}} members | '''namespace''' name<br />{{keypress|Tab}} members |
ISLISP | ('''defclass''' name (base-class) ((x ''':initform''' 0 ''':accessor''' get-x ''':initarg''' x)) (''':abstractp''' nil)) | | | |
| constructor | destructor | finalizer[13] |
---|
ABAP Objects | '''methods constructor''' «'''importing''' parameter = argument»<br />'''method constructor.''' instructions '''endmethod.''' [14] | colspan=2 |
APL (Dyalog) | '''∇''' name
''':Implements Constructor''' «''':Base''' «expr»»
instructions
'''∇''' | | '''∇''' name
''':Implements Destructor'''
instructions
'''∇''' |
C++ | class'''('''«parameters»''') '''«''': '''initializers [15] »''' { '''instructions''' }''' | '''~'''class''' { '''instructions''' }''' | |
C# | class'''('''«parameters»''') { '''instructions''' }''' | '''void Dispose{ '''instructions''' }''' | '''~'''class''' { '''instructions''' }''' |
D | '''this('''«parameters»''') { '''instructions''' }''' | | '''~this { '''instructions''' }''' |
eC | class''' {''' instructions '''}''' | ~class''' {''' instructions '''}''' | |
Java | class'''('''«parameters»''') { '''instructions''' }''' | | '''void finalize { '''instructions''' }''' |
Eiffel | [16] | | [17] |
Objective-C (Cocoa) | '''- (id)init { '''instructions...''' return self; }''' or <br /> '''- (id)'''initWithFoo''':'''parameter «bar''':'''parameter ...»''' { '''instructions...''' return self; }''' | '''- (void)dealloc { '''instructions''' }''' | '''- (void)finalize { '''instructions''' }''' |
Swift | '''init('''«parameters»''') { '''instructions''' }''' | '''deinit { '''instructions''' }''' | |
Python | '''def __init__(self'''«''', '''parameters»'''):'''<br /> {{keypress|Tab}} instructions | | '''def __del__(self):'''<br /> {{keypress|Tab}} instructions |
Visual Basic .NET | '''Sub New('''«parameters»''')'''<br /> instructions <br />'''End Sub''' | '''Sub Dispose'''<br /> instructions <br />'''End Sub''' | '''Overrides Sub Finalize'''<br /> instructions <br />'''End Sub''' |
Xojo | '''Sub Constructor('''«parameters»''')'''<br /> instructions <br />'''End Sub''' | '''Sub Destructor'''<br /> instructions <br />'''End Sub''' | |
PHP | '''function __construct('''«parameters»''') { '''instructions''' }''' | '''function __destruct { '''instructions''' }''' | |
Perl | '''sub new { my ($class'''«''', '''parameters»''') = @_; my $self = {}; '''instructions ...''' bless($self, $class); return $self; }''' | '''sub DESTROY { my ($self) = @_; '''instructions''' }''' | |
Raku | '''submethod BUILD {''' instructions '''}''' or<br /> «'''multi''' » '''method new('''««$self''':''' »parameters»''') { self.bless(*, '''field1 '''=>''' value1, ...''');''' ... instructions '''}''' | '''submethod DESTROY {''' instructions '''}''' | |
Ruby | '''def initialize'''«'''('''parameters''')'''» <br /> instructions <br /> '''end''' | colspan=2 |
Windows PowerShell | colspan=3 |
OCaml | '''initializer''' instructions [18] | colspan=2 |
F# | '''do''' instructions or<br /> '''new('''parameters''') = ''' expression [19] | '''member this.Dispose =''' instructions | '''override this.Finalize =''' instructions |
JavaScript | '''function''' name'''('''«parameters»''')''' '''{''' instructions '''}''' [20] | colspan=2 |
JavaScript (ES6) | constructor( «parameters»''') {''' instructions '''}''' |
COBOL | [21] | colspan=2 |
Cobra | '''cue init('''parameters''')'''<br />{{keypress|Tab}} '''base.init'''<br />{{keypress|Tab}} instructions | '''def''' dispose<br />{{keypress|Tab}} instructions | |
ISLISP | ('''defmethod''' initialize-object ((instance <class-name>) initvalues) | | |
| public | private | protected | friend |
---|
ABAP Objects | '''public section.<ref name="abapsection">Scope identifier must appear once in the file declaration, all variable declarations after this scope identifier have his scope, until another scope identifier or the end of class declaration is reached</ref> data''' field '''type''' type'''.''' | '''private section.<ref name="abapsection" /> data''' field '''type''' type'''.''' | '''protected section.<ref name="abapsection" /> data''' field '''type''' type'''.''' | [22] |
APL (Dyalog) | ''':Field Public''' field «'''←''' value» | ''':Field''' «'''Private'''» field «'''←''' value» | | |
C++ | '''public: '''type field''';''' | '''private: '''type field''';''' | '''protected: '''type field''';''' | [23] |
C# | '''public '''type field «'''=''' value»''';''' | '''private '''type field «'''=''' value»''';''' | '''protected '''type field «'''=''' value»''';''' | '''internal''' type field «'''=''' value»''';''' |
D | | '''package''' type field «'''=''' value»''';''' |
Java | '''protected '''type field «'''=''' value»''';''' | type field «'''=''' value»''';''' |
eC | '''public''' type field''';''' | '''private''' type field''';''' |
Eiffel | '''feature'''<br /> field: TYPE | '''feature {NONE}'''<br /> field: TYPE | '''feature {'''current_class'''}''' <br /> field: TYPE | '''feature {FRIEND}''' <br /> field: TYPE |
Objective-C | '''@public '''type field''';''' | '''@private '''type field''';''' | '''@protected '''type field''';''' | '''@package '''type field''';''' |
Swift | colspan=4 |
Smalltalk | [24] | |
Python | '''self.'''field''' = '''value [25] | [26] | colspan=2 |
Visual Basic .NET | '''Public '''field''' As '''type «'''=''' value» | '''Private '''field''' As '''type «'''=''' value» | '''Protected '''field''' As '''type «'''=''' value» | '''Friend '''field''' As '''type «'''=''' value» |
Xojo | '''Public '''field''' As '''type «'''=''' value» | '''Private '''field''' As '''type «'''=''' value» | '''Protected '''field''' As '''type «'''=''' value» | |
PHP | '''public $'''field «'''=''' value»''';''' | '''private $'''field «'''=''' value»''';''' | '''protected $'''field «'''=''' value»''';''' | |
Perl | '''$self->{'''field'''} = '''value''';''' | colspan=3 |
Raku | '''has'''« type »$'''.'''field« '''is rw'''» | '''has'''« type »$'''!'''field | colspan=2 |
Ruby | '''[[sigil (computer programming)|@]]'''field '''=''' value | |
Windows PowerShell | '''Add-Member '''<br />«'''-MemberType '''»'''NoteProperty '''<br />«'''-Name '''»Bar «'''-Value '''»value<br />'''-InputObject '''variable | colspan=3 |
OCaml | '''val''' «'''mutable'''» field '''=''' value | rowspan=2 |
F# | | '''let''' «'''mutable'''» field '''=''' value | |
JavaScript | '''this.'''field''' = '''value <br /> '''this'''["field"] = value | | | |
COBOL | | level-number field clauses.[27] | | |
Cobra | '''var''' field «'''as''' type» «'''=''' value» | '''var''' '''__'''field «'''as''' type» «'''=''' value» | '''var''' '''_'''field «'''as''' type» «'''=''' value» | |
ISLISP | (field ''':initform''' value ''':accessor''' accessor-name ''':initarg''' keyword) | | | | |
| basic/void method | value-returning method |
---|
ABAP Objects | '''methods''' name «'''importing''' parameter = argument» «'''exporting''' parameter = argument» «'''changing''' parameter = argument» «'''returning value('''parameter''')'''»<br />'''method''' name'''.''' instructions '''endmethod.''' [28] | [29] |
APL (Dyalog) | '''∇''' «left argument» name «right arguments»
instructions
'''∇''' | '''∇''' result '''←''' «left argument» name «right arguments»
instructions
'''∇''' |
C++[30] type foo'''('''«parameters»''');''' The implementation of methods is usually provided in a separate source file, with the following syntax
type class'''::'''foo'''('''«parameters»''') { '''instructions''' }''' [31]
| '''void '''foo'''('''«parameters»''') { '''instructions''' }''' | type foo'''('''«parameters»''') { '''instructions ... '''return''' value'''; }''' |
C# |
D |
Java |
eC | '''void '''««type of 'this'»'''::'''»foo'''('''«parameters»''') { '''instructions''' }''' | type ««type of this»'''::'''»foo'''('''«parameters»''') { '''instructions ... '''return''' value'''; }''' |
Eiffel | foo '''(''' «parameters» ''')'''<br /> '''do''' <br /> instructions <br /> '''end''' | foo '''(''' «parameters» '''):''' TYPE <br /> '''do''' <br /> instructions... <br /> '''Result''' := value <br /> '''end''' |
Objective-C | '''- (void)'''foo«''':'''parameter «bar''':'''parameter ...»»''' { '''instructions''' }''' | '''- ('''type''')'''foo«''':'''parameter «bar''':'''parameter ...»»''' { '''instructions... '''return''' value'''; }''' |
Swift | '''func '''foo'''('''«parameters»''') { '''instructions''' }''' | '''func '''foo'''('''«parameters»''') -> '''type''' { '''instructions... '''return''' value''' }''' |
Python | '''def '''foo'''(self'''«''',''' parameters»'''):<br /> {{keypress|Tab}} '''instructions | '''def '''foo'''(self'''«''',''' parameters»'''):<br /> {{keypress|Tab}} '''instructions'''<br /> {{keypress|Tab}} return '''value |
Visual Basic .NET | '''Sub '''Foo'''('''«parameters»''') <br /> '''instructions''' <br /> End Sub''' | '''Function '''Foo'''('''«parameters»''') As '''type''' <br /> '''instructions <br /> ... <br /> '''Return''' value<br /> '''End Function''' |
Xojo | '''Sub '''Foo'''('''«parameters»''') <br /> '''instructions''' <br /> End Sub''' | '''Function '''Foo'''('''«parameters»''') As '''type''' <br /> '''instructions <br /> ... <br /> '''Return''' value<br /> '''End Function''' |
PHP | '''function '''foo'''('''«parameters»''')«: void» { '''instructions''' }''' | '''function '''foo'''('''«parameters»''')«: '''type'''» { '''instructions ... '''return''' value'''; }''' |
Perl | '''sub '''foo''' { my ($self'''«''', '''parameters»''') = @_; '''instructions''' }''' | '''sub '''foo''' { my ($self'''«''', '''parameters»''') = @_; '''instructions ... '''return''' value'''; }''' |
Raku | «'''has''' »«'''multi''' »'''method '''foo'''('''««$self''': ''' »parameters»''') { '''instructions''' }''' | «'''has''' «type »»«'''multi''' »'''method '''foo'''('''««$self''': ''' »parameters»''') { '''instructions ... '''return''' value'''; }''' |
Ruby | '''def '''foo«'''('''parameters''')'''» <br /> instructions <br /> '''end''' | '''def '''foo«'''('''parameters''')'''» <br /> instructions <br /> expression resulting in return value <br /> '''end''' <br /> or <br /> '''def '''foo«'''('''parameters''')»''' <br /> instructions <br /> '''return''' value <br /> '''end''' |
Windows PowerShell | '''Add-Member '''«'''-MemberType'''»''' ScriptMethod '''«'''-Name'''» foo «'''-Value'''»''' { '''«'''param('''parameters''')'''»''' '''instructions''' } -InputObject '''variable | '''Add-Member '''«'''-MemberType'''»''' ScriptMethod '''«'''-Name'''» foo «'''-Value'''»''' { '''«'''param('''parameters''')'''»''' '''instructions ... '''return''' value '''} -InputObject '''variable |
OCaml | '''method''' foo «parameters» '''=''' expression |
F# | '''member this.'''foo'''('''«parameters»''') =''' expression |
JavaScript | '''this.'''method''' = function('''«parameters»''') {'''instructions'''}''' <br /> name«.'''prototype.'''method''' = function('''«parameters»''') {'''instructions'''}''' [32] | '''this.'''method''' = function('''«parameters»''') {'''instructions... '''return''' value''';}''' <br /> name«.'''prototype.'''method''' = function('''«parameters»''') {'''instructions... '''return''' value;'''}''' |
Javascript (ES6) | foo'''('''«parameters»''') {'''instructions'''}''' | foo'''('''«parameters»''') {'''instructions... '''return''' value;'''}''' |
COBOL | '''METHOD-ID.''' foo'''.'''<br/>«'''DATA DIVISION.'''<br/>'''LINKAGE SECTION.'''<br/>parameter declarations»<br/>'''PROCEDURE DIVISION'''« '''USING''' parameters»'''.''' '''END METHOD''' foo'''.''' | '''METHOD-ID.''' foo'''.'''<br/>'''DATA DIVISION.'''<br/>'''LINKAGE SECTION.'''<br/>«parameter declarations»<br/>result-var declaration<br/>'''PROCEDURE DIVISION'''« '''USING''' parameters» '''RETURNING''' result-var'''.''' '''END METHOD''' foo'''.''' |
Cobra | '''def''' foo'''('''parameters''')'''<br />{{keypress|Tab}} instructions | '''def''' foo'''('''parameters''') as''' type<br />{{keypress|Tab}} instructions<br />{{keypress|Tab}} '''return''' value | |
ISLISP | ('''defgeneric''' method (arg1 arg2))<br>('''defmethod''' method ((arg1 <class1> arg2 <class2>) ...) | | |
| read-write | read-only | write-only |
---|
ABAP Objects | colspan=3 |
APL (Dyalog) | ''':Property''' Bar
'''∇''' result '''← Get'''
instructions
'''∇'''
'''∇ Set''' arguments
instructions
'''∇'''
''':EndProperty''' Bar | ''':Property''' Bar
'''∇''' result '''← Get'''
instructions
'''∇'''
''':EndProperty''' Bar | ''':Property''' Bar
'''∇ Set''' arguments
instructions
'''∇'''
''':EndProperty''' Bar |
C++ | colspan=3 |
C# | type Bar '''{<br/> get { '''instructions ... '''return '''value''';''' '''}<br/> set { '''instructions''' } }''' | type Bar '''{ get { '''instructions ... '''return '''value''';''' '''} }''' | type Bar '''{ set { '''instructions''' } }''' |
D | '''@property''' type bar''' { '''instructions ... '''return '''value''';''' '''} <br /> @property''' type bar'''('''type value''') { '''instructions ... '''return '''value''';''' '''}''' | '''@property''' type bar''' { '''instructions ... '''return '''value''';''' '''}''' | '''@property''' type bar'''('''type value''') { '''instructions ... '''return '''value''';''' '''}''' |
eC | '''property''' type Bar '''{<br/> get { '''instructions ... '''return '''value''';''' '''}<br/> set { '''instructions''' } }''' | '''property''' type Bar '''{ get { '''instructions ... '''return '''value''';''' '''} }''' | '''property''' type Bar '''{ set { '''instructions''' } }''' |
Java | colspan=3 |
Objective-C 2.0 (Cocoa) | '''@property (readwrite)''' type bar''';''' <br /> and then inside
@implementation <br /> '''- ('''type''')'''bar''' { '''instructions''' }''' <br /> '''- (void)'''setBar''':('''type''')'''value''' { '''instructions''' }''' | '''@property (readonly)''' type bar''';''' <br /> and then inside
@implementation <br /> '''- ('''type''')'''bar''' { '''instructions''' }''' | |
Swift | '''var''' bar ''':''' type '''{ get { '''instructions''' } set'''«'''('''newBar''')'''»''' { '''instructions''' } }''' | '''var''' bar ''':''' type '''{ '''instructions''' }''' | |
Eiffel | '''feature''' -- Access <br />x: TYPE '''assign''' set_x<br /> '''feature''' -- Settings <br /> set_x (a_x: '''like''' x) '''do''' instructions '''ensure''' x_set: verification '''end''' | | |
Python | '''def''' setBar'''(self, '''value'''):''' <br />{{keypress|Tab}} instructions'''<br />def''' getBar'''(self):<br />{{keypress|Tab}} '''instructions<br />{{keypress|Tab}} '''return''' value<br />bar''' = property('''getBar''',''' setBar''')''' [33] | '''def''' getBar'''(self):''' <br />{{keypress|Tab}} instructions<br />{{keypress|Tab}} '''return''' value<br />bar''' = property('''getBar''')''' | '''def''' setBar'''(self, '''value'''): '''<br />{{keypress|Tab}} instructions<br />bar''' = property(fset = '''setBar''')''' |
Visual Basic .NET | '''Property '''Bar''' As '''type<br />'''Get<br />'''instructions<br />'''Return''' value<br />'''End Get<br />Set (ByVal '''Value''' As '''type''')'''<br />instructions'''<br />End Set<br />End Property''' | '''ReadOnly Property '''Bar''' As '''type<br />'''Get<br />'''instructions<br />'''Return''' value<br />'''End Get<br />End Property''' | '''WriteOnly Property '''Bar''' As '''type<br />'''Set (ByVal '''Value''' As '''type''')'''<br />instructions<br />'''End Set<br />End Property''' |
Xojo | '''ComputedProperty '''Bar''' As '''type<br />'''Get<br />'''instructions<br />'''Return''' value<br />'''End Get<br />Set (ByVal '''Value''' As '''type''')'''<br />instructions'''<br />End Set<br />End ComputedProperty''' | '''ComputedProperty '''Bar''' As '''type<br />'''Get<br />'''instructions<br />'''Return''' value<br />'''End Get<br />End ComputedProperty''' | '''ComputedProperty '''Bar''' As '''type<br />'''Set ('''value''' As '''type''')'''<br />instructions<br />'''End Set<br />End ComputedProperty''' |
PHP | '''function __get('''$property''') {<br/> switch ('''$property''') {<br/> case '''{{'}}Bar{{'}}''' : '''instructions ... '''return''' value''';<br/> } }<br />function __set('''$property''', '''$value''') {<br/> switch ('''$property''') {<br/> case '''{{'}}Bar{{'}}''' : '''instructions'''<br/> } }''' | '''function __get('''$property''') {<br/> switch ($'''property''') {<br/> case '''{{'}}Bar{{'}}''' : '''instructions ... '''return''' value''';<br/> } }''' | '''function __set('''$property''', '''$value''') {<br/> switch ('''$property''') {<br/> case '''{{'}}Bar{{'}}''' : '''instructions'''<br/> } }''' |
Perl | '''sub''' Bar {<br /> '''my''' $self = '''shift''';<br /> '''if''' ('''my''' $Bar = '''shift''') {<br /> # setter<br /> $self->{Bar} = $Bar;<br /> return $self;<br /> } '''else''' {<br /> # getter<br /> '''return''' $self->{Bar}; <br /> }<br />} | '''sub''' Bar {<br /> '''my''' $self = '''shift''';<br /> '''if''' ('''my''' $Bar = '''shift''') {<br /> # read-only<br /> '''die''' "Bar is read-only\n";<br /> } '''else''' {<br /> # getter<br /> '''return''' $self->{Bar}; <br /> }<br />} | '''sub''' Bar {<br /> '''my''' $self = '''shift''';<br /> '''if''' ('''my''' $Bar = '''shift''') {<br /> # setter<br /> $self->{Bar} = $Bar;<br /> return $self;<br /> } '''else''' {<br /> # write-only<br /> '''die''' "Bar is write-only\n"; <br /> }<br />} |
Raku | colspan=3 |
Ruby | '''def '''bar <br /> instructions <br /> expression resulting in return value <br /> '''end''' <br /> '''def '''bar'''=('''value''')''' <br /> instructions <br /> '''end''' | '''def '''bar <br /> instructions <br /> expression resulting in return value <br /> '''end''' | '''def '''bar'''=('''value''')''' <br /> instructions <br /> '''end''' |
Windows PowerShell | '''Add-Member '''<br/>«'''-MemberType '''»'''ScriptProperty '''<br/>«'''-Name '''»Bar «'''-Value '''»'''{''' instructions ... '''return''' value''' }''' <br/>«'''-SecondValue '''»'''{''' instructions '''}''' <br/>'''-InputObject '''variable | '''Add-Member '''<br/>«'''-MemberType '''»'''ScriptProperty '''<br/>«'''-Name '''»Bar «'''-Value '''»'''{''' instructions ... '''return''' value'''}''' <br/>'''-InputObject '''variable | '''Add-Member '''<br/>«'''-MemberType '''»'''ScriptProperty '''<br/>«'''-Name '''»Bar '''-SecondValue {''' instructions '''}''' <br/>'''-InputObject '''variable |
OCaml | colspan=3 |
F# | '''member this.'''Bar '''with get =''' expression '''and set('''value''') =''' expression | '''member this.'''Bar '''=''' expression | '''member this.'''Bar '''with set('''value''') =''' expression |
JavaScript (ES6) | '''get''' bar'''('''«parameters»''')''' '''{''' instructions ... '''return '''value'''}'''s'''et '''bar'''('''«parameters»''') { '''instructions '''} ''' | get bar'''('''«parameters»''')''' '''{''' instructions ... '''return '''value'''}''' | '''set '''bar'''('''«parameters»''') { '''instructions '''}''' |
COBOL | '''METHOD-ID. GET PROPERTY''' bar'''.'''<br/>'''DATA DIVISION.'''<br/>'''LINKAGE SECTION.'''<br/>return-var declaration<br/>'''PROCEDURE DIVISION RETURNING''' return-var'''.''' '''END METHOD.'''<br/>'''METHOD-ID. SET PROPERTY''' bar'''.'''<br/>'''DATA DIVISION.'''<br/>'''LINKAGE SECTION.'''<br/>value-var declaration<br/>'''PROCEDURE DIVISION USING''' value-var'''.''' '''END METHOD.''' | '''METHOD-ID. GET PROPERTY''' bar'''.'''<br/>'''DATA DIVISION.'''<br/>'''LINKAGE SECTION.'''<br/>return-var declaration<br/>'''PROCEDURE DIVISION RETURNING''' return-var'''.''' '''END METHOD.''' | '''METHOD-ID. SET PROPERTY''' bar'''.'''<br/>'''DATA DIVISION.'''<br/>'''LINKAGE SECTION.'''<br/>value-var declaration<br/>'''PROCEDURE DIVISION USING''' value-var'''.''' '''END METHOD.''' |
Cobra | '''pro''' bar «'''as''' type»<br />{{keypress|Tab}} '''get'''<br />{{keypress|Tab}}{{keypress|Tab}} instructions<br />{{keypress|Tab}}{{keypress|Tab}} '''return''' value<br />{{keypress|Tab}} '''set'''<br />{{keypress|Tab}}{{keypress|Tab}} instructions | '''get''' bar «'''as''' type»<br />{{keypress|Tab}} instructions<br />{{keypress|Tab}} '''return''' value | '''set''' bar «'''as''' type»<br />{{keypress|Tab}} instructions |
ISLISP | |
| read-write | read-only | write-only |
---|
ABAP Objects | colspan=3 |
C++ | colspan=3 |
C# | type Bar '''{ get; set; }''' | type Bar '''{ get; private set; }''' | type Bar '''{ private get; set; }''' |
D | colspan=3 |
Java | colspan=3 |
Objective-C 2.0 (Cocoa) | '''@property (readwrite)''' type bar''';''' <br /> and then inside @implementation <br /> '''@synthesize''' bar''';''' | '''@property (readonly)''' type bar''';''' <br /> and then inside @implementation <br /> '''@synthesize''' bar''';''' | |
Swift | '''var''' bar ''':''' type | '''let''' bar ''':''' type | |
Eiffel | | | |
Python | '''@property'''<br />'''def''' bar('''self'''):<br />{{keypress|Tab}}instructions<br />'''@'''bar'''.setter'''<br />'''def''' bar('''self''', value):<br />{{keypress|Tab}}instructions | '''@property'''<br />'''def''' bar('''self'''):<br />{{keypress|Tab}}instructions | bar '''= property'''<br />'''@'''bar'''.setter'''<br />'''def''' bar('''self''', value):<br />{{keypress|Tab}}instructions |
Visual Basic .NET | '''Property''' Bar '''As''' type« '''=''' initial_value» (VB 10) | | |
PHP | | | |
Perl[34] | '''use''' '''base''' '''qw'''(Class::Accessor);<br />'''__PACKAGE__'''->'''mk_accessors'''('Bar'); | '''use''' '''base''' '''qw'''(Class::Accessor);<br />'''__PACKAGE__'''->'''mk_ro_accessors'''('Bar'); | '''use''' '''base''' '''qw'''(Class::Accessor);<br />'''__PACKAGE__'''->'''mk_wo_accessors'''('Bar'); |
Raku | colspan=3 |
Ruby | '''attr_accessor''' :bar | '''attr_reader''' :bar | '''attr_writer''' :bar |
Windows PowerShell | | | |
OCaml | colspan=3 |
F# | '''member val''' Bar '''=''' value '''with get, set''' | | |
COBOL | level-number bar clauses '''PROPERTY.''' | level-number bar clauses '''PROPERTY «WITH» NO SET.''' | level-number bar clauses '''PROPERTY «WITH» NO GET.''' |
Cobra | '''pro''' bar '''from var''' «'''as''' type» | '''get''' bar '''from var''' «'''as''' type» | '''set''' bar '''from var''' «'''as''' type» | |
unary | binary | function call |
---|
ABAP Objects | colspan=3 |
C++ | type '''operator''' symbol ''' { '''instructions''' }''' | type '''operator''' symbol '''('''type operand2''') { '''instructions''' }''' | type '''operator ('''«parameters»''') { '''instructions''' }''' |
C# | '''static '''type''' operator '''symbol'''('''type operand''') { '''instructions''' }''' | '''static '''type''' operator '''symbol'''('''type operand1''', '''type operand2''') { '''instructions''' }''' | |
D | type '''opUnary(string''' s''') if ('''s''' == "'''symbol'''") { '''instructions''' }''' | type '''opBinary(string''' s''')('''type operand2''') if ('''s''' == "'''symbol'''") { '''instructions''' }''' <br /> type '''opBinaryRight(string''' s''')('''type operand1''') if ('''s''' == "'''symbol'''") switch ('''s''') { '''instructions''' }''' | type '''opCall('''«parameters»''') { '''instructions''' }''' |
Java | rowspan=2 colspan=3 |
Objective-C |
Swift | '''func''' symbol'''('''operand1 ''':''' type''') -> '''returntype''' { '''instructions''' }''' (outside class) | '''func''' symbol'''('''operand1 ''':''' type1''', '''operand2 ''':''' type2''') -> '''returntype''' { '''instructions''' }''' (outside class) | |
Eiffel[35] | op_name '''alias "'''symbol'''":''' TYPE <br />'''do''' instructions '''end''' | op_name '''alias "'''symbol'''" ('''operand: TYPE1'''):''' TYPE2 <br />'''do''' instructions '''end''' | |
Python | '''def __'''opname'''__(self): <br /> {{keypress|Tab}} '''instructions'''<br /> {{keypress|Tab}} return '''value | '''def __'''opname'''__(self, '''operand2'''): <br /> {{keypress|Tab}} '''instructions'''<br /> {{keypress|Tab}} return '''value | '''def __call__(self'''«''', '''parameters»'''): <br /> {{keypress|Tab}} '''instructions'''<br /> {{keypress|Tab}} return '''value |
Visual Basic .NET | '''Shared Operator '''symbol'''('''operand''' As '''type''') As '''type'''<br /> '''instructions''' <br /> End Operator''' | '''Shared Operator '''symbol'''('''operand1''' As '''type''', '''operand2''' As '''type''') As '''type'''<br /> '''instructions''' <br /> End Operator''' | |
Xojo | '''Function Operator_'''name'''('''operand''' As '''type''') As '''type'''<br /> '''instructions''' <br /> End Function''' | colspan=2 |
PHP | [36] | '''function __invoke('''«parameters»''') { '''instructions''' }''' (PHP 5.3+) |
Perl | '''use overload "'''symbol'''" => sub { my ($self) = @_; '''instructions''' };''' | '''use overload "'''symbol'''" => sub { my ($self, '''$operand2''', '''$operands_reversed''') = @_; '''instructions''' };''' | |
Raku | «'''our''' «type »»«'''multi''' »'''method prefix:<'''symbol'''> ('''«$operand''':''' »''') {''' instructions ... '''return '''value''';''' '''}''' or<br /> «'''our''' «type »»«'''multi''' »'''method postfix:<'''symbol'''> ('''«$operand''':''' »''') {''' instructions ... '''return '''value''';''' '''}''' or<br /> «'''our''' «type »»«'''multi''' »'''method circumfix:<'''symbol1 symbol2'''> ('''«$operand''':''' »''') {''' instructions ... '''return '''value''';''' '''}''' | «'''our''' «type »»«'''multi''' »'''method infix:<'''symbol'''> ('''«$operand1''':''' » type operand2''') {''' instructions ... '''return '''value''';''' '''}''' | «'''our''' «type »»«'''multi''' »'''method postcircumfix:<> ('''«$self''':''' » «parameters»''') {''' instructions '''}''' |
Ruby | '''def '''symbol <br /> instructions <br /> expression resulting in return value <br /> '''end''' | '''def '''symbol'''('''operand2''')''' <br /> instructions <br /> expression resulting in return value <br /> '''end''' | |
Windows PowerShell | rowspan=2 colspan=3 |
OCaml |
F# | '''static member ('''symbol''')''' operand '''=''' expression | '''static member ('''symbol''')''' '''('''operand1''',''' operand2''') =''' expression | |
COBOL | colspan=3 |
ISLISP | colspan=3 |
|
read-write | read-only | write-only |
---|
ABAP Objects | colspan=3 |
APL (Dyalog) | ''':Property Numbered Default''' name
'''∇''' result '''← Get'''
instructions
'''∇'''
'''∇ Set''' arguments
instructions
'''∇'''
''':EndProperty''' Bar | ''':Property Numbered Default''' Bar
'''∇''' result '''← Get'''
instructions
'''∇'''
''':EndProperty''' Bar | ''':Property Numbered Default''' Bar
'''∇ Set''' arguments
instructions
'''∇'''
''':EndProperty''' Bar |
C++ | type'''& operator[]('''type index''') { '''instructions''' }''' | type '''operator[]('''type index''') { '''instructions''' }''' | |
C# | type '''this['''type index'''] { <br /> get{ '''instructions''' } <br /> set{ '''instructions''' } }''' | type '''this['''type index'''] { get{ '''instructions''' } }''' | type '''this['''type index'''] { set{ '''instructions''' } }''' |
D | type '''opIndex('''type index''') { '''instructions''' }''' <br /> type '''opIndexAssign('''type value''', '''type index''') { '''instructions''' }''' | type '''opIndex('''type index''') { '''instructions''' }''' | type '''opIndexAssign('''type value''', '''type index''') { '''instructions''' }''' |
Java | colspan=3 |
Objective-C (recent Clang compiler) | | '''- (id)objectAtIndexedSubscript:(NSUInteger)'''index''' { '''instructions''' return '''value'''; }''' or<br />'''- (id)objectForKeyedSubscript:(id)'''index''' { '''instructions''' return '''value'''; }''' | '''- (void)setObject:(id)'''value''' atIndexedSubscript:(NSUInteger)'''index''' { '''instructions''' }''' or<br />'''- (void)setObject:(id)'''value''' forKeyedSubscript:(id)'''index''' { '''instructions''' }''' |
Swift | '''subscript ('''index''' : '''type''') -> '''returntype''' { get { '''instructions''' } set'''«'''('''newIndex''')'''»''' { '''instructions''' } }''' | '''subscript ('''index''' : '''type''') -> '''returntype''' { '''instructions''' }''' | |
Eiffel | bracket_name '''alias "[]" ('''index: TYPE'''):''' TYPE '''assign''' set_item <br />'''do''' instructions '''end''' <br /> set_item '''('''value: TYPE; index: TYPE'''):''' <br />'''do''' instructions '''end''' | bracket_name '''alias "[]" ('''index: TYPE'''):''' TYPE <br />'''do''' instructions '''end''' | |
Python | '''def __getitem__(self, '''index'''): <br /> '''{{keypress|Tab}} instructions <br /> {{keypress|Tab}} '''return''' value <br /> '''def __setitem__(self, '''index''', '''value'''):''' <br /> {{keypress|Tab}} instructions | '''def __getitem__(self, '''index'''): <br /> '''{{keypress|Tab}} instructions <br /> {{keypress|Tab}} '''return''' value | '''def __setitem__(self, '''index''', '''value'''):''' <br /> {{keypress|Tab}} instructions |
Visual Basic .NET | '''Default Property Item('''Index''' As '''type''') As '''type''' <br /> Get <br /> '''instructions''' <br /> End Get <br /> Set(ByVal '''Value''' As '''type''') <br /> '''instructions''' <br /> End Set <br /> End Property''' | '''Default ReadOnly Property Item('''Index''' As '''type''') As '''type''' <br /> Get <br /> '''instructions''' <br /> End Get <br /> End Property''' | '''Default WriteOnly Property Item('''Index''' As '''type''') As '''type''' <br /> Set(ByVal '''Value''' As '''type''') <br /> '''instructions''' <br /> End Set <br /> End Property''' |
PHP | [37] |
Perl | [38] |
Raku | «'''our''' «type »»«'''multi''' »'''method postcircumfix:<[ ]> is rw ('''«$self''':''' » type $index''') {''' instructions ... '''return '''value''';''' '''}''' or<br /> «'''our''' «type »»«'''multi''' »'''method postcircumfix:<{ }> is rw ('''«$self''':''' » type $key''') {''' instructions ... '''return '''value''';''' '''}''' | «'''our''' «type »»«'''multi''' »'''method postcircumfix:<[ ]>('''«$self''':''' » type $index''') {''' instructions ... '''return '''value''';''' '''}''' or<br /> «'''our''' «type »»«'''multi''' »'''method postcircumfix:<{ }> ('''«$self''':''' » type $key''') {''' instructions ... '''return '''value''';''' '''}''' | |
Ruby | '''def []('''index''')''' <br /> instructions <br /> expression resulting in return value <br /> '''end''' <br /> '''def []=('''index, value''')''' <br /> instructions <br /> '''end''' | '''def []('''index''')''' <br /> instructions <br /> expression resulting in return value <br /> '''end''' | '''def []=('''index, value''')''' <br /> instructions <br /> '''end''' |
Windows PowerShell | rowspan=2 colspan=3 |
OCaml |
F# | '''member this{{Not a typo|.}}Item with get('''index''') =''' expression '''and set '''index value '''=''' expression | '''member this{{Not a typo|.}}Item with get('''index''') =''' expression | '''member this{{Not a typo|.}}Item with set '''index value '''=''' expression |
COBOL | colspan=3 |
Cobra | '''pro['''index «'''as''' type»'''] as''' type<br />{{keypress|Tab}} '''get'''<br />{{keypress|Tab}}{{keypress|Tab}} instructions<br />{{keypress|Tab}}{{keypress|Tab}} '''return''' value<br />{{keypress|Tab}} '''set'''<br />{{keypress|Tab}}{{keypress|Tab}} instructions | '''get['''index «'''as''' type»'''] as''' type<br />{{keypress|Tab}} instructions<br />{{keypress|Tab}} '''return''' value | '''set['''index «'''as''' type»'''] as''' type<br />{{keypress|Tab}} instructions | |
| object member | class member | namespace member |
---|
| method | field | property |
---|
ABAP Objects | '''x->'''method'''(«'''parameters»''').''' [39] | '''x->'''field | | '''x=>'''field or '''x=>'''method'''(«'''parameters<ref name="abapparam" />»''').''' | |
C++ | '''x.'''method'''('''parameters''')''' or<br />'''ptr->'''method'''('''parameters''')''' | '''x.'''field or<br />'''ptr->'''field | | cls'''::'''member | ns'''::'''member |
Objective-C | '''[x '''method«''':'''parameter «bar''':'''parameter ...»»''']''' | '''x->'''field | '''x.'''property (2.0 only) or<br />'''[x '''property''']''' | '''['''cls method«''':'''parameter «bar''':'''parameter ...»»''']''' | |
Smalltalk | '''x '''method«''':'''parameter «bar''':'''parameter ...»» | | | cls method«''':'''parameter «bar''':'''parameter ...»» | |
Swift | '''x.'''method'''('''parameters''')''' | | '''x.'''property | cls'''.'''member | |
APL (Dyalog) | left argument» '''x.'''method «right argument(s)» | '''x.'''field | '''x.'''property | cls'''.'''member | ns'''.'''member |
C# | '''x.'''method'''('''parameters''')''' |
Java | |
D | '''x.'''property |
Python |
Visual Basic .NET |
Xojo |
Windows PowerShell | '''['''cls''']::'''member |
F# | | cls'''.'''member |
eC | '''x.'''method«'''('''parameters''')'''» | '''x.'''field | '''x.'''property | cls'''::'''member | ns'''::'''member |
Eiffel | '''x.'''method«'''('''parameters''')'''» | '''x.'''field | | '''{'''cls'''}.'''member | rowspan=2 |
Ruby | | '''x.'''property | cls'''.'''member |
PHP | '''x->'''method'''('''parameters''')''' | '''x->'''field | '''x->'''property | cls'''::'''member | ns'''\'''member |
Perl | '''x->'''method«'''('''parameters''')'''» | '''x->{'''field'''}''' | | cls'''->'''method«'''('''parameters''')'''» | ns'''::'''member |
Raku | '''x.'''method«'''('''parameters''')'''» or<br /> '''x!'''method«'''('''parameters''')'''» | '''x.'''field or<br /> '''x!'''field | | cls'''.'''method«'''('''parameters''')'''» or<br /> cls'''!'''method«'''('''parameters''')'''» | ns'''::'''member |
OCaml | '''x#'''method «parameters» | | |
JavaScript | '''x.'''method'''('''parameters''')'''<br />'''x'''["method"]'''('''parameters''')''' | '''x.'''field<br />'''x'''["field"] | '''x.'''property<br />'''x'''["property"] | '''cls.'''member<br />'''cls'''["member"] | |
COBOL | '''INVOKE x''' '''"'''method'''"''' «'''USING''' parameters» «'''RETURNING''' result» or<br/>'''x::"'''method'''"'''«'''('''«parameters»''')'''» | | property '''OF x''' | '''INVOKE''' cls '''"'''method'''"''' «'''USING''' parameters» «'''RETURNING''' result» or<br/>cls'''::"'''method'''"'''«'''('''«parameters»''')'''» or<br/>property '''OF''' cls | |
Cobra | '''x.'''method«'''('''parameters''')'''» | '''x.'''field | '''x.'''property | cls'''.'''member | ns'''.'''member | |