-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
revert #13064 #13401
revert #13064 #13401
Conversation
# Note: `[]` currently gives: `Error: no generic parameters allowed for ...` | ||
type(default(T)[i]) | ||
|
||
macro genericParams*(T: typedesc): untyped {.since: (1, 1).} = |
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 shouldn't be removed IMO. The other stuff I agree should be removed
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.
I think it should be removed. The informal reason is: shitty typedesc
. There is even a PR that I am currently working on that would make this solution impossible #11959
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.
Can you point out whats bad about it here? (sorry for disrupting your crusade :p)
I think preventing to return typedesc is a very bad idea. I can understand it for procs, but not for templates/macros.
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.
nothing against returning typedesc from a macro. But putting typedesc in any form of container, such as array or tuple is bad. What do you think (int,float)
is? Is it the type for a tuple of int and float, or is it a tuple containing the type int
and the type float
? If you print the result of this proc you will get somthing that will be something different when parsed. There are probably more problems under the hood that I can't name, because typedesc always has hidden problems.
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.
I just found out that this function does return a tuple type, not a tuple value. And and since a tuple type does not have accessors, there accessors were added to typetraits
.
@nitely has styleCheck set to error for nim-regex which is causing this failure. https://github.com/nitely/nim-regex/blob/master/config.nims#L4 |
that was consistency with
indeed, and good point. But that should be fixed instead of reverted. I can look into it.
feel free to suggest a better name
I don't see what you'd want to revert that. If it's broken please show a failing example. |
The problem is, the entire pull request should be reverted and set back to the drawing board. A fresh start of the idea. As I said earlier this PR should not be accepted in the first place. For
Both And regarding your request to fix your implementation. No I don't want to do that. I don't want to fix "features" that should not have been introduced in the first place. |
that was my 1st approach #8554 but that "bad design" you're referring to was actually suggested by @zah, see: #8554 (comment) And I agree with him, returning a type tuple results in a better, more reusable API.
Like I said here #13401 (comment), I will fix |
Well, I disagree. The concept to have
Here are some types that you should test: type
VectorElementType = SomeNumber | bool
Vec*[N : static[int], T: VectorElementType] = object
arr*: array[N, T]
Vec4*[T: VectorElementType] = Vec[4,T]
Vec4f* = Vec4[float32]
MyTupleType = (int,float,string)
MyGenericTuple[T] = (T,int,float)
MyGenericAlias = MyGenericTuple[string]
MyGenericTuple2[T,U] = (T,U,string)
MyGenericTuple2Alias[T] = MyGenericTuple2[T,int]
MyGenericTuple2Alias2 = MyGenericTuple2Alias[float] |
I added those and a few others in #13423; that PR just fixes the bug in lenTuple but doesn't change its name
doAssert genericParams(Foo[float, string]) is (float, string)
|
/cc @krux02 not related to this PR but FYI: I couldn't post an issue on https://krux02@bitbucket.org/krux02/tensordslnim/jira/ since that page is unrepsonsive. |
@timotheecour Thanks for the info. For some reason I never implemented exist status propagation because it wasn't needed for local testing. When the tensordsl package moved to important packages, I simply forgot that part. Thank your for the notification. It is fixed now. |
now that #13433 and #13423 have been merged, IMO the only thing left is renaming lenTuple to tupleLen and lenVarargs to varargsLen. |
and with #13639 that just got merged, I think nothing is left to do here; should this be closed? |
#13064 should not have passed quality control.
issues with
lenTuple
:tupleLen
, because a length tuple is a tuple containing dimensions like with height and depath.issues with
get
:get
is too universal. It is very likely to clash with symbols of other libraries that also have aget
proc.issues with
genericParams
:genericParams
returns a tuple oftypedesc
values. This is exactly the type oftypedesc
usage that we agreed to drop from the language. Same with arrays of typedesc.Edit:
from my experience with macros I can tell, that you need for every typetrait proc a variant that takes
NimNode
, because that is the way you get types within macros, both in the argument form as well as in the result ofgetTypeInst
. It is not possible to call the procs operating ontypedesc
from a macro. But if you have theNimNode
proc implemented, it is trivial to infer a version that works ontypedesc
with a macro. It is also nice if the macros api and the typetraits api have matching names.