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

Missing/nice to have info about Macros #55

Open
tomaskallup opened this issue Oct 3, 2024 · 3 comments
Open

Missing/nice to have info about Macros #55

tomaskallup opened this issue Oct 3, 2024 · 3 comments

Comments

@tomaskallup
Copy link
Contributor

I would like to slowly compose a list of stuff that I bump into while playing around with macros, so we can later on improve the docs.

Working with $typeof

  • I found it a bit difficult to find what is available on the result of $typeof, currently it's listed on top of the reflection page. The documentation for $typeof should ideally mention that the attributes are at the top.
  • nameof missing from the attributes

Working with $membersof

  • .get should be mentioned in the docs
@joshring
Copy link
Contributor

joshring commented Oct 3, 2024

Add an example for working with macros and generics

macro @test_list(a)
{
  var $Type = $typeof(a);
  $if $defined(a[0]) &&& $Type.typeid == List(<$typeof(a[0])>).typeid:
    $echo("LIIIIST");
  $else
    $echo("NOT LIST");
  $endif
}

@joshring
Copy link
Contributor

joshring commented Oct 12, 2024

macro @example(t_slice)
{
	var $type = $typeof(t_slice);
}

Error: A type must be followed by either (...) or '.'.

This is not an error

macro @example(t_slice)
{
	var $Type = $typeof(t_slice);
}

from: c3lang/c3c#1553

@sa-tasche
Copy link

#76

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

3 participants