5

i've been reading through the ocstyle source code and i ran into methods that have '-' before them. here's is an example

@rule(modifier[...] + (sizedCType | anyIdentifier) + -implementedProtocols +
      (Present(Regex(r'[(),<>:]')) | sp(1)) + Literal('*')[...])

there are times that methods have a '-' before the method call right before it returns. is there anyone who can identify what this is called or point me to some other resource? i've tried looking for it and came to the conclusion here would be my best bet.

1
  • Almost look like a repr of a pyparsing/grammar specification Commented Aug 14, 2013 at 18:38

2 Answers 2

3

In python, you can define a magic function for a number of unary operators. The one in the example you give is defined by __neg__(self) usually. I recommend searching the source to see what that function does in your example.

For reference, there's a list of "magic functions" available here.

Sign up to request clarification or add additional context in comments.

Comments

0

Whatever type implementedProtocols belongs to defines its own semantics for the negation operator. You'd have to look at the documentation or the source to figure out what those semantics are.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.