Skip to content

Only execute when names don't exist #20

@aplavin

Description

@aplavin

Related to #16, but not a duplicate.

I'm trying to finally transition from a custom startup.jl snippet to using BasicAutoloads. Struggling with how already-defined symbols are handled...

Non-defined symbols: in #16, you suggest writing like

["geomean", "harmmean", "mad", "quantile", "percentile", "weights"] => :(isdefined(Main, :quantile) || using StatsBase),

But that doesn't work the same as just putting using StatsBase:

# when I put [...] => :(using StatsBase)
julia> mad
 │ Package StatsBase not found, but a package named StatsBase is available from a registry. 
 │ Install package?
 │   (@v1.11) pkg> add StatsBase 

# when I put [...] => :(isdefined(Main, :quantile) || using StatsBase)
julia> mad
┌ Info: Failed to run `isdefined(Main, :quantile) || using StatsBase`
│   exception =
│    ArgumentError: Package StatsBase not found in current path.
└    - Run `import Pkg; Pkg.add("StatsBase")` to install the StatsBase package.
ERROR: UndefVarError: `mad` not defined in `Main`
Suggestion: check for spelling errors or missing imports.

Can BasicAutoloads check whether names exist and only run the RHS when they don't?

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