-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
It's really nice that the implementation of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, forcing to use symbols, existing Ident
s or full paths by default makes sense.
Unsafe
can also be imported in small scopes makes for good design.
Other than the two minor comments on implementation, this looks good.
src/main/scala/gestalt/api.scala
Outdated
prefix.select(name) | ||
} | ||
|
||
TypeSelect(prefix, parts.last) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a fold over TypeTree
not TermTree
.
It is possible to eliminate the recursive calls if we handle the head
specially not the last
.
parts.tail.foldLeft[TypeTree](TypeSelect(tree,parts.head)){
(prefix, name) =>
TypeSelect(prefix, name)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a type select such as scala.collection.Set
, only the last part is TypeSelect
, scala.collection
is still Select
.
src/main/scala/gestalt/api.scala
Outdated
prefix.select(name) | ||
} | ||
|
||
Select(prefix, parts.last) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done more easily
parts.foldLeft[TermTree](tree) {
(prefix, name) =>
Select(prefix, name)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, thanks a lot.
This is a simple while practical solution to the hygiene problem: it still allows programmers to do the hack if
scala.gestalt.options.unsafe
is imported. By default, only fully-qualified name or symbol-based name is supported.When scala supports literal types, we can do better with the API: