Skip to content

Is "access pattern" error? #26

Description

@ababup1192

In pony access pattern page:

https://patterns.ponylang.org/async/access.html

The following source code is

use collections = "collections"

actor SharedRegisters
  let _data: collections.Map[String, I64] = _data.create()

  be write(name: String, value: I64) =>
    """
    Write to the named register, setting its value to the given value.
    """
    _data(name) = value

  be read(name: String, fn: {(I64)} val) =>
    """
    Read the value of the named register and pass it to the given function.
    A register which has never been written to will have a value of zero.
    """
    fn(try _data(name) else 0 end)

http://playground.ponylang.org/?gist=441163b1de339e775b926d60ff5039d7

This causes the following error

main.pony:17:22: call is not partial but the method is - a question mark is required after this call
    fn(try _data(name) else 0 end)
                     ^
    Info:
    packages/collections/map.pony:46:36: method is here
      fun apply(key: box->K!): this->V ? =>

Maybe I think a partial function.

 be read(name: String, fn: {(I64)} val) =>
    """
    Read the value of the named register and pass it to the given function.
    A register which has never been written to will have a value of zero.
    """
    fn(try _data(name)? else 0 end)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions