-
Notifications
You must be signed in to change notification settings - Fork 7
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
Name of the types? #31
Comments
@Datseris what do you think? |
Gimme a couple of days because things are going crazy at work, and I'll have a detailed look. |
Just a quick note before I have a detailed look, and also because your reply is necessary: Why should you prefer the complex |
In terms of typing The macro isn't anything complex. It just adds Using the types is only needed if someone wants to create MusicXML. For parsing these are not needed anyway. I am going to add another macro that imports all the MusicXML types if someone doesn't use anything else. @importMX # imports all the MusicXML types. |
I'll give you my take on it based on my experience developing packages so far, and you can take it or leave it. Even if you don't take it, at least spend some time thinking about it (since I spend so much time writing it down).
So, as far as I can tell, all the complications I mention above become trivially resolved if (1) you don't export |
The first reason is because these types are MusicXML's types. All the types have the same name in the original MusicXML: The second reason is that there is no point in changing my type names just because there are similar type names in other packages. So I don't want to change the name of the types just for the sake of Julia's usage. I wanted to export all the types at first, but because of the conflicts, I am skeptical to do this. Although, macros seem scary they are not. I agree with the video you sent, but remember that these macros don't do anything special. That video is about abusing them. We don't want to remove a language's feature (C/C++ also use macros a lot.).
Mixed usage is very easy: @MX begin
Note(stuff) # becomes MX.Note
MIDI.Note(other_stuff) # remains untouched
end or @MX(Note(stuff)) == Note(other_stuff)
# translates to: MX.Note(stuff) == Note(other_stuff) I have seen these kinds of stuff in other packages too:
|
We already named
Note
type asNoteX
type to prevent conflict withMIDI.jl
. Now, I remembered thatTime
type is also available in theDates
package, which is a standard library in Julia, and one cannot use these two together.I am wondering if I shouldn't export the types at all and instead introduce an alias for the package (like how I did inside
IntelVectorMath.jl
):which allows calling the types like:
The alias can be different things like
MX
,Mx
,mx
,MXL
,mxl
,Mxl
etc.In addition, I can also write a macro that translates every call to MusicXML's types and add to
MusicXML.
them.For example:
will be translated to:
People can easily mix different types from different libraries by using either
()
orbegin end
This also allows me to define MIDI version of the types inside MIDI.jl or some other package like MetaMidi.jl
The text was updated successfully, but these errors were encountered: