Please help understand the syntax

In the source code for summarysize.jl

Line 63:
(ss::SummarySize)(@nospecialize obj) = _summarysize(ss, obj)

Line 88 and 89:

(::SummarySize)(obj::Symbol) = 0
(::SummarySize)(obj::SummarySize) = 0

Can someone help explain the syntax used here?

1 Like

Let’s say you have an instance s of type SummarySize - this function definition makes it so that using s as a function to be called becomes possible (like s(arg)).

(I’ve also moved this thread to “Usage”, since it’s not really a question about how the internals of julia or its design work :slight_smile:)


@Sukera Thank you. Can you point me to the official documentation?

These are called “functors” - you’ll find many questions that mention them here on Discourse.

There’s a short section of the docs that demonstrate them here: Methods · The Julia Language


Another name for them in julia is “callable structs”, though I’m not sure there’s a seperate page of documentation available.


@EP-Guy This is really helpful. Thank you so much!