Skip to content

Implement static data types #25199

@ggb-sw

Description

@ggb-sw

Summary

Although nim allows static functions that can be executed at compile time, what it lacks (and exists in other languages) are static data types.

At present it is possible to get around this with:

var global_variable: string

proc some_function(value: string) =
  if global_variable == "": global_variable = value
  return global_variable

But it would be tidier (i.e. not polluting the global namespace) if one could code the same as thing as:

proc some_function(value: string) =
  static local_static: string
  if local_static == "": local_static = value
  return local_static

Description

Both for simple memorization and for cumulative totals, and to do this without polluting global namespace.

Alternatives

No response

Examples

No response

Backwards Compatibility

No response

Links

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions