Compiler icon indicating copy to clipboard operation
Compiler copied to clipboard

doc : improve explanation on namespace

Open Grummfy opened this issue 7 years ago • 8 comments

When I read the following topics http://discourse.hoa-project.net/t/hoa-compiler-keyword-identifier-clash/252 I can understand that namespace permit to avoid collision between namespace but also to isolate each namespace (correct?).

So it could be intresting to add a section in the namespace documentation about that, on the why using namespace and they purpose with a good example ;)


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Grummfy avatar Jun 02 '17 08:06 Grummfy

There is already a section for that, https://hoa-project.net/En/Literature/Hack/Compiler.html#Namespaces.

Thoughts?

Hywan avatar Jun 02 '17 08:06 Hywan

Indeed, I don't know if it's new or if I don't understand it at first. But honestly for me it was not clear when I read this doc (and I read it several times ...)

Grummfy avatar Jun 02 '17 08:06 Grummfy

Is it clear now?

Hywan avatar Jun 02 '17 08:06 Hywan

it seems, I will re-read it and close the issue if it is. Otherwise I will try to suggest something.

Grummfy avatar Jun 02 '17 09:06 Grummfy

I know this was supposed to be an issue on namespace documentation, but since it was related to my forum post, I wanted to make a suggestion for documentation on lexer mechanism. The lexer behaviour is sometimes mysterious if you haven't looked at the source to see this:

#\G(?|<regex>)#<option> (from line 277 in Lexer.php)

After that point, you can specify your tokens with the help of an online regex parser, but I don't think it's obvious at all without this knowledge.

KurtAhn avatar Jun 14 '17 00:06 KurtAhn

The \G(?|…) construction should not have any impact on your regular expression definitions. Was it a source of a bug on your side?

Hywan avatar Jun 14 '17 06:06 Hywan

I think the problem was with space characters. After reading your post, I tried replicating problems I had (or thought I had), but I wasn't able to. What I noticed instead was this:

%skip space \s
%token boolean true|false
//%token boolean true | false

The first boolean token works as expected, while the second one doesn't. Maybe I'm just being dumb, but I think the spacing behaviour is a little weird if you don't know exactly how the parser generator works. If you specify spaces to be skipped, isn't it natural to think spaces don't matter in token specification? I guess what I'm saying is I didn't know the lexer would just take true | false part and embed it into the \G(?|...) expression without more preprocessing before passing it through a regex engine, and that became clear only after I looked at the source.

KurtAhn avatar Jun 14 '17 12:06 KurtAhn

@Grummfy what is your opinion about the documentation at the moment?

flip111 avatar Jan 25 '19 15:01 flip111