Various syntaxes for calling a method in OO languages

I know:

C ++, Java, etc. others:

object.method() , object.method(arg)  

Objective-C:

[object method] , [object method:arg]

Smalltalk:

object method   , object method: arg

PHP, Perl

object->method(), object->method(arg)
$object->method;
$object->method($arg1, $arg2, ...);

OCaml

object#method  ,  object#method args

CLOS

(method object) ,  (method object arg) 

And even, I used:

method object
method(object)

Can you name other alternative ways to send a message to an object (I think this is the right term) in different programming languages?

+3
source share
5 answers

" " - CLOS ( OO Common Lisp), (method object arg) ( defgeneric method defmethod /); , , Dylan Python (, PEAK), method(object, arg).

generic/method ( Common Lisp pioneered, AFAIK) , - - " , ( , , ;-). Visitor (, this ), ! -)

+1

:

VB.NET , #, /:

stream.WriteLine "Hello"
Dim x = stream.ReadLine

IDE ( , ).

, VB.NET ( ) Call, :

Call stream.WriteLine("Hello") '// is the same as'
stream.WriteLine("Hello")
'// This won’t compile:'
Call stream.WriteLine "Hello"
+1

Perl, :

$object->method;
$object->method($arg1, $arg2, ...);

( , :

method $object $arg1, $arg2...;
+1

Source: https://habr.com/ru/post/1722186/


All Articles