Skip to content

Conversation

@nogurenn
Copy link
Contributor

Closes #1710

Is there a one-liner/short code I can use to illustrate the difference of whitebox and blackbox contexts? Something like

funcThatShowsDiff(macro blackImpl)
funcThatShowsDiff(macro whiteImpl)

@SethTisue
Copy link
Member

SethTisue commented Sep 1, 2020

The underscore on _final is peculiar, I think. I understand that it's there to avoid the clash with the keyword final, but I think it would be better to avoid the clash some other way. I'll add a commit with a different renaming.

re: one-line examples, I can't think of anything offhand; I think the PR is mergeable regardless. I like what you did by adding a link.

@SethTisue SethTisue merged commit 95ffc19 into scala:master Sep 1, 2020
@SethTisue
Copy link
Member

thank you!

@nogurenn
Copy link
Contributor Author

nogurenn commented Sep 2, 2020

I usually do _foo for specifically localized implementations where a foo name makes sense in the scope also, treating _foo as like a temp variable. I forgot how I came up with it, or where I picked it up. I remember thinking it's better than val someVagueTempVariableName to me. Maybe I got it from another language that implements _foo for internals, and exposes foo in its interfaces?

// an example whose form makes more sense in code like nodejs
val persons = {
  val data = db.run(personsQuery.result)
  val _persons = ... // code further processing `data`
  
  return _persons
}

@SethTisue
Copy link
Member

SethTisue commented Sep 2, 2020

another language that implements _foo for internals, and exposes foo in its interfaces?

I see that in Scala codebases too, including my own.

In this context I didn't consider it actually wrong, just unnecessarily distracting.

For avoiding a clash with a keyword, note that Scala also allows:

val `final` = ...

@nogurenn
Copy link
Contributor Author

nogurenn commented Sep 2, 2020

No problem from my end! Just thought it's a nice reminder to re-assess my coding practices from time to time

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

Successfully merging this pull request may close these issues.

Update macros doc for tree creation to use blackbox/whitebox context

2 participants