WebAssembly / WebAssembly/component-model

feature: pure function mark

Open
#321 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
1.4k
Forks
130
Avg merge
2d 1h
Merged PRs (30d)
15

Description

I need a mechanism to mark functions as having no side effects (pure functions).

Most external interfaces come with state, so I recommend having side effects by default and adding the @pure(after https://github.com/WebAssembly/component-model/issues/58) tag if it is a pure function

Because pure functions and side-effect functions have different behaviors in dead code elimination analysis.

Pure functions such as wasi:clocks/monotonic-clock/now can be deleted directly from the control flow if they are not used.

However, functions such as wasi:random/random/get-random-u64 may change external state, so even if their return value is not used, they cannot be deleted.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the issue and the linked WebAssembly Component Model discussion at https://github.com/WebAssembly/component-model/issues/58. Determine how a pure-function marker should represent the distinction between removable pure calls and side-effecting calls such as the WASI examples. Done means the repository has an agreed mechanism for marking purity and for applying that distinction during dead code elimination.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.