{"id":16572299,"url":"https://github.com/jonocarroll/overloading","last_synced_at":"2026-02-12T14:32:10.505Z","repository":{"id":185237730,"uuid":"622978320","full_name":"jonocarroll/overloading","owner":"jonocarroll","description":"Source code for a blog post on function overloading","archived":false,"fork":false,"pushed_at":"2023-04-03T13:00:12.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-19T20:49:21.501Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jcarroll.com.au/2023/04/03/polyglot-overloading/","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonocarroll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-03T12:59:47.000Z","updated_at":"2023-04-03T13:46:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"da41dfd8-e77a-47c3-bea2-e2458d7c514e","html_url":"https://github.com/jonocarroll/overloading","commit_stats":null,"previous_names":["jonocarroll/overloading"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonocarroll/overloading","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Foverloading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Foverloading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Foverloading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Foverloading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonocarroll","download_url":"https://codeload.github.com/jonocarroll/overloading/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Foverloading/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29368688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T21:27:03.911Z","updated_at":"2026-02-12T14:32:10.489Z","avatar_url":"https://github.com/jonocarroll.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Comparing Function Overloading \n\nIn each of these cases, attempt to call the same function with a single argument \nand with two arguments. The first should result in the argument times 100, the second \nshould result in the product of the arguments\n\n## Haskell\n\nHaskell has pattern matching to 'overload' functions, but doesn't deal well with \noptional arguments (potentially via `Data.Maybe`). Since the overall signature shape \nmust be constant, this passes either a length-1 list or a length-2 list.\n\n```\n$ cd haskell\n$ ghc dispatch.hs -o dispatchHaskell\n$ ./dispatchHaskell\n# 500.0\n# 25.0\n\n$ cd ..\n```\n\n## Fortran90\n\nFortran supports function overloading via `interface` so we can call different functions \nwith different function signatures using the same 'call'. This calls a function with one \nargument and a function with two.\n\n```\n$ cd f90\n$ gfortran dispatch.f90 -o dispatchFortran\n$ ./dispatchFortran\n#   500.000000\n#   25.0000000\n\n$ cd ..\n```\n\n## R S3/S4\n\nS3 can dispatch based on class of the first argument, so this passes a number (length-1 vector) \nand a list containing two numbers.\n\n```\n$ cd R\n$ Rscript dispatchS3.R   \n# [1] 500\n# [1] 25\n```\n\nS4 can dispatch based on the entire signature, so this defines a function with two numeric \narguments and another with one numeric argument, one missing argument.\n\n```\n$ Rscript dispatchS4.R   \n# [1] 500\n# [1] 25\n\n$ cd ..\n```\n\n## Julia\n\nJulia has simple function declaration and dispatch depending on the entire signature, \nso this defines two functions; one with one argument, one with two.\n\n```\n$ cd Julia\n$ julia dispatch.jl\n# 500\n# 25\n```\n\nJulia can also be more specific with the arguments. Here type annotations are added \nto further specialise the functions.\n\n```\n$ julia dispatch_typed.jl\n# 500\n# 1000.0\n# 25\n# 50.0\n\n$ cd ..\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Foverloading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonocarroll%2Foverloading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Foverloading/lists"}