Skip to content

Commit

Permalink
Bump gha workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
penelopeysm committed Jan 23, 2025
1 parent ce24263 commit 40e0299
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
- name: Checkout your repository using git
uses: actions/checkout@v4
- name: Install, build, and upload your site output
uses: withastro/action@v1
uses: withastro/action@v3
with:
path: .
node-version: 18
node-version: 20
package-manager: pnpm@latest

deploy:
Expand All @@ -38,4 +38,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
uses: actions/deploy-pages@v4
16 changes: 11 additions & 5 deletions src/content/posts/2025-01-23-multiple-dispatch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ publishDate: "2025-01-23"
tags: []
---

## Python

A common pattern in object-oriented programming is to have a default implementation on a parent class and to reuse that in a child class.
In Python, this is done using the `super()` function.

Expand All @@ -27,6 +29,8 @@ calling Parent.foo

This means that you get to reuse any logic in the parent class that is supposed to be shared amongst all children, but you also get to do specialised things in the child class if you need to.

## Julia

Now, how do we do this in Julia?

In Julia, types cannot subtype other concrete types, so the equivalent of the 'parent class' must be an abstract type.
Expand Down Expand Up @@ -86,23 +90,25 @@ Quite often, the parent and child functions are called `foo` and `_foo`, which i

In Python, when you see `super()`, that immediately tells you that it's trying to call a parent method, so the _intent_ of the code is clear.

## Functional

Notice that in a functional language, say Haskell, you _have_ to use the latter method:

```haskell
class Parent where
foo :: IO ()
class Parent a where
foo :: a -> IO ()

-- the argument seems unnecessary, but imagine that innerFoo was a function
-- which needed inputs to run correctly
parentFoo :: Parent -> IO ()
parentFoo :: Parent a => a -> IO ()
parentFoo _ = putStrLn "calling Parent.foo"

data Child = Child

instance Parent Child where
foo c = do
putStrLn "calling Child.foo"
innerFoo c
parentFoo c
```

But: (1) Haskell doesn't pretend that it lets you reuse function names; and (2) unlike Julia, Haskell actually enforces the interface, in that if you try to define an `instance Parent IllegalChild` without a corresponding definition of `foo`, it won't compile.
But: (1) Haskell at least doesn't pretend that it lets you reuse function names; and (2) unlike Julia, Haskell actually enforces the interface, in that if you try to define an `instance Parent IllegalChild` without a corresponding definition of `foo`, it won't compile.

0 comments on commit 40e0299

Please sign in to comment.