Skip to content

(call)

function calls

clojure
(call receiver? args?)

Where:

  1. receiver: the function being called (the func in func()) *
  2. args: arguments supplied to the call *

Matching:

  1. regular calls, e.g. func()
  2. method calls, e.g. obj.method()
  3. calls with generator expressions, e.g. func(x for x in items)

Behavior

  • When a call uses a generator expression as its sole argument, you can match it with (gen ...) in the args slot.

Examples

Find print calls that emit string messages.

clojure
(call (id "print") (arg 1 (str)))

Selects in lines { 1 } but not in { 2, 3 }:

python
print("hello")
print(123)
log("hello")

Locate sum calls that iterate over prices with a generator expression.

clojure
(call (id "sum") (gen (id price)))

Selects in lines { 1 } but not in { 2, 3 }:

python
total = sum(price for price in prices)
total = sum(cost for cost in costs)
total = sum([price for price in prices])

Find open calls that pass a binary mode.

clojure
(call (id "open") (arg 2 (str /b/)))

Selects in lines { 1, 3 } but not in { 2 }:

python
open(path, "rb")
open(path, "r")
open(path, "wb")

Arguments

receiver

• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
(:kind) (:ref) (:text) (call) (fun) (gen) (id) (num) (str) (:into) (:and) (:or) (:not) (:replace) (:capture)

args

(arg)
(gen)
(:into) (:and) (:or) (:not) (:text) (:kind) (:replace) (:capture)

Copyright © 2022-present Semantic Works, Inc.