{"id":16701099,"url":"https://github.com/arnobl/structural-typing-examples","last_synced_at":"2026-02-16T10:38:58.082Z","repository":{"id":145959060,"uuid":"80043810","full_name":"arnobl/structural-typing-examples","owner":"arnobl","description":"Examples in various programming languages about how structural typing is supported","archived":false,"fork":false,"pushed_at":"2018-11-16T11:02:20.000Z","size":57,"stargazers_count":20,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-06T00:32:47.642Z","etag":null,"topics":["object-oriented","programming-language","structural-typing","type-system"],"latest_commit_sha":null,"homepage":null,"language":"Eiffel","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnobl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-25T18:28:14.000Z","updated_at":"2023-11-24T05:22:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"8a29a433-0c81-43a5-ad92-cc57a8cd97c4","html_url":"https://github.com/arnobl/structural-typing-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/arnobl/structural-typing-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2Fstructural-typing-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2Fstructural-typing-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2Fstructural-typing-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2Fstructural-typing-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnobl","download_url":"https://codeload.github.com/arnobl/structural-typing-examples/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobl%2Fstructural-typing-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29506252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"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":["object-oriented","programming-language","structural-typing","type-system"],"created_at":"2024-10-12T18:28:40.998Z","updated_at":"2026-02-16T10:38:58.024Z","avatar_url":"https://github.com/arnobl.png","language":"Eiffel","funding_links":[],"categories":[],"sub_categories":[],"readme":"Examples in various object-oriented programming languages about how structural typing is supported.\nSolutions with languages that do not support structural typing are also detailed with a workaround solution (e.g., using an adapter).\n\nContributions (pull requests) are welcome.\n\n## Contribute\n\nContributions with languages having some support of structural typing are preferred. The examples must use explicit structural typing features provided by the language (e.g., a Java solution using reflexivity will not be accepted).\n\nPlease follow this format (take a look at the existing solutions):\n- a folder with the name of the programming language;\n- an executable script file named `run` that compiles and executes the program on Linux;\n- a `README` file that explains how the language supports structural typing (or not, and in this case explanations about the workaround are expected);\n- The code that follows the scenario.\n\n## Scenario\n\nA type `Duck` exists with two functions `quack` and `dance` that return a string object.\n\nA type `Wolf` exists with three functions: `quack`, `dance`, and `eat`. The functions `quack` and `dance` have the same prototype than in `Duck` and respectively return: `\"QUACK QUACK WHOO\"` and `\" ¯\\_()_/¯ \"`. The function `eat` takes a `Duck` instance as parameter and returns the string: `\" 😈 \"`. `Wolf` must not be defined as a `Duck` (i.e., no nominal typing). \n\nA type `Mallard` (implicitly or explicitly) implements the `Duck` type: `quack` returns `\"quack quack\"` and `dance` returns `\" _/¯ \"`.\n\nThe program creates a `Wolf` called `wolf`, then declares a `Duck` called `theDuck`. The `wolf` then takes the form of a `Duck` through `theDuck`. A `Mallard` called `aDuck` is then created.\n\nIn a dedicated method called `twoDucksAlone` that takes as arguments two ducks `d1` and `d2` :\n\n`d1` and `d2` quack.\n\n`d1` and `d2` dance.\n\nAfter this method call with `aDuck` and `theDuck` as parameters:\n\n`wolf` eats `aDuck`.\n\nThe output of the program should be:\n\n```\nquack quack\nQUACK QUACK WHOO\n _/¯ \n ¯\\_()_/¯ \n 😈 \n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobl%2Fstructural-typing-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnobl%2Fstructural-typing-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobl%2Fstructural-typing-examples/lists"}