One of the things I like about Objective-C is the use of infix arguments when calling a method.

[myDictionary setObject:myObject forKey:@"key"];

where the method name is setObject:forKey:.

Does any other language do this?

  • Other languages tend to achieve this with named arguments, and typically make its use optional.
    – rwong
    May 24, 2015 at 5:29
  • 1
    Ocaml has optional named arguments for functions. May 24, 2015 at 7:00
  • Scala's infix mechanics are weird, but they let you do cool things. Haskell allows you to convert any 2 argument function into infix by calling it while it's surrounded in backticks. It also makes any purely symbolically-named function into infix automatically. May 24, 2015 at 12:44
  • 3
    @Carcigenicate: The question is not about infix operators, it is about infix arguments, i.e. arguments which are interspersed in between the parts of the method name, e.g. for a method named foo:bar: it would be called foo: 1 bar: 2 instead of foo:bar:(1, 2). May 24, 2015 at 13:13

1 Answer 1


Since Objective-C inherited its core object-oriented features (minus categories and protocols), including the syntax, from Smalltalk, there's obviously at least Smalltalk that has the same syntax. Plus, all of the Smalltalk descendants such as Self, Newspeak and Fancy.

  • Interesting. I didn't know Smalltalk was it's roots. May 24, 2015 at 8:04
  • 1
    Objective-C is basically C + Smalltalk + types. Java is Objective-C - C, or, IOW, Smalltalk + types. ECMAScript is Scheme + NewtonScript (which is based on Self) with a little bit of Act-1 (which is based on Self). Ruby is Smalltalk + Perl. Smalltalk heritage runs deep in modern OO. May 24, 2015 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.