Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter names in procedural types #10

Closed
jameshfisher opened this issue Jan 24, 2011 · 1 comment
Closed

Parameter names in procedural types #10

jameshfisher opened this issue Jan 24, 2011 · 1 comment

Comments

@jameshfisher
Copy link

In the tutorial there's the example "procedural type":

type
  TCallback = proc(x: int)

proc echoItem(x: int) =
  echo(x)

proc forEach(callback: TCallback) =
  const
    data = [2, 3, 5, 7, 11]
  for d in items(data):
    callback(d)

forEach(echoItem)

Why is it necessary to give parameters names when only declaring a type?
I feel like I should be able to do:

type
  TCallback = proc(int)

Is this in the works?

@Araq
Copy link
Member

Araq commented Jan 26, 2011

That is too ambiguous to handle and some consider parameter names a nice form of documentation... However, in the works are type descriptions using the same syntax as expressions:
int * int # short for tuple[a, b: int]
int -> int # short for proc (a: int): int

Hm, now that makes int * int -> int a proc (a: tuple[a,b:int]): int
Damn. Any idea?
--> Discussion in forum (http://force7.de/heimdall/).

krux02 pushed a commit to krux02/Nim that referenced this issue Jan 11, 2022
krux02 pushed a commit to krux02/Nim that referenced this issue Jan 11, 2022
66: [DOC] Link to the spec project instead of nim-lang#10 r=saem a=haxscramper



Co-authored-by: haxscramper <haxscramper@gmail.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants