Skip to content

Only engage when a name is used #21

@aplavin

Description

@aplavin

I'm trying to finally transition from a custom startup.jl snippet to using BasicAutoloads, and another thing I'm struggling with is how new definitons are handled.
Basically, using a name should run the RHS, using .... But defining a new name shouldn't.
Eg, I should be able to do both:

# OK:
julia> mad([1,2,3])
 │ Package StatsBase not found, but a package named StatsBase is available from a registry. 
 │ Install package?
 │   (@v1.11) pkg> add StatsBase 
 └ Select environment:
<...>
1.4826022185056018
# (in a new REPL)
# shouldn't try importing the package:
julia> mad = "sane"
 │ Package StatsBase not found, but a package named StatsBase is available from a registry. 
 │ Install package?

The snippet I'm using now does that by only handling function/macro calls, as in

if Meta.isexpr(ast, [:macrocall, :call]) && first(ast.args)  symbolslist
    ...

In practice it works well, almost perfect :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions