Skip to content

Do not use __ before garbage collection API  #1648

Closed
@aminya

Description

@aminya

Copied from #1559 (comment)

Description

I want to propose to use a better notation for the public assembly script functions. There is no need to prepend __ before the end of the functions.

Reasoning

Usually, __ is used before something that should not be used, not something that every developer needs to call manually. TypeScript provides many ways to prevent name conflicting that are better than prefixing underscores.

I would recommend renaming __collect to collect. If someone wants these functions to have different names (rare), they can do:

import { collect as as_collect } from '...'

Using __ and similar notations are used in languages like C that do not have any notion of namespace or module and the names conflict with each other. This is not certainly the case for AssemblyScript.

Example from other languages

Julia, the only language I know that allows triggering garbage collection manually, uses GC.gc() function for triggering garbage collection. GC is a module (namespace) and gc is the function name.

https://docs.julialang.org/en/v1/base/base/#Base.GC.gc

Potential Methods

  1. There was one suggested by @MaxGraey here:
    Rewrite runtime, switch to tracing GC and bootstrap #1559 (comment)

  2. If I was the one who makes the decision, I would just use the power of TypeScript namespaces and modules. In TypeScript it is already possible to rename the functions using as when importing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions