Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

g-gundam/ProblematicAnimals.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProblematicAnimals

This project exists solely to debug and hopefully solve a problem I'm having with Pluto.jl notebooks.

Start with very simple code

module ProblematicAnimals

abstract type AbstractAnimal end
struct Cat <: AbstractAnimal end
struct Dog <: AbstractAnimal end

sound(cat::Cat) = "meow"
sound(dog::Dog) = "bark"

# Structs defined in a notebook seem to become invisible while in this function.
function why(a::AbstractAnimal)
    sound(a)
end

export AbstractAnimal
export Cat
export Dog
export sound
export why

end

It should work like this.

julia> cat = Cat()
Cat()

julia> sound(cat)
"meow"

julia> why(cat)
"meow"

However, I can't get a subtype defined in a notebook to work.

struct Pig <: AbstractAnimal end

sound(pig::Pig) = "oink"

pig = Pig()

sound(pig) # "oink"

why(pig) # The `sound(pig::Pig)` function is invisible to the why(a) function.

error

How can I get why(pig) to work?

ProblematicAnimals.sound(pig::Pig) = "oink"

About

demonstrating a Pluto.jl problem and hoping to find a solution

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages