Replies: 1 comment 1 reply
-
Thanks for your input! By looking at Rust docs there are at least 3 kinds of macros. C macros are implemented as a part of preprocessor, and they intersect in functionality with string mixins. A better version of both would be something like quoting/unquoting in Lisp and some functional languages. This is the direction I'm looking in atm. Also the whole Did you look into Zig? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello and happy holidays! It's been some time since the last time I wrote a discussion or opened an issue but I keep an eye on Vox and I check for news almost daily and as always I'm more than impressed to see the amazing continuous work you do!
A little update on me (skip this paragraph if you don't care):
At this point, I'm working on "libd" which is a system library for the D programming language (haven't uploaded the code yet). This has started at me writing this library on Vox but the current limitations stopped me after one point because I realized that I won't be able to make some parts of the library as I wanted so I had to just wait. To be honest there are probably 2-3 things that I needed and one of them would probably only be needed for 2-3 functions but implementing things with the limitations I have now and later change the design would be harder to do than just write the language on D an then port it right away as soon I see that the features that I want have been implemented (and this will be very ease because of the similarities of D and Vox). So yeah the good news are that even tho Vox is not stable and fully featured yet, I'm working on the library right now so Vox will have it right away when I will be able to port it so no need for extra waiting! Anyway, for the actual topic:
C templates are simple, you write something like:
#define create_var(type, name, value) type name = value
.So "type", "name", and "value" are what we would call the "parameters" in function terms. So there are two things that happen here and make the whole system amazing. The first things is that these "parameters" can be anything! For instance, in the example I gave, you can write something like the following to "expand" the macro:
crate_var(int, num, 20)
. So here, we accepted a type as the first parameter, an identifier (or plain tokens) as the second parameter and a value (or expression) as the third parameter. And it just works!!! Fully freedom to do what I want and the compiler doesn't try to "protect" my by saving me from doing mistakes (damn how much I FUCKING HATE language that have this mentality) or trying code that is "hard to read". The second thing is that I gave a simple name to the parameters and used that name to every place that I want to replace them withing my macro. I didn't had to use things like "alias" or any other of that crap. The compiler will just replace the "thing" that the parameters will take inside the macro. This approach is simple, powerful, headache free and it just works! I love it!!!!NOTE: This paragraph will just be a rant about the way templates work in D so just skip if you're not in the mood to read
D templates from the other hand.... Just why??? Why they are so annoying and undocumented? You have no idea how many questions I had to make to the D forums to just make what I wanted to do with them. I hate them with a great passion. First of all, we got three of them. Templates, Mixins and Mixin templates. Just why they can't be simple and just work? Now the C system is not perfect and I understand people not want to copy paste it. But I thought that you change things to make them better not worse and annoying. Anyways, I could rant for an hour and link you my posts in the D forums (type "rempas" in the search bar to see for yourself if you are interested) but there is no way to do that. I think you got me. Of course D has so many features, I'm not saying that it is a bad language. It is actually a great language and at this point, people that need features that Vox doesn't have, should use D rather than C++, Rust or any other language that tries to be a "better c". But my point is that D just does some things that you are asking "just why they are doing that?". Like it just doesn't make sense man. I mean you get my mood at this point. I don't have to explain more.
So I just spent your time once again to tell you that I fully support you on taking your time and have any priorities that you want without felling any pressure neither from me or anyone else. But please when you decide on working on templates/macros, please don't make the mess Dlang has made. One kind of macros is fine. It's not bad having a language that doesn't have a lot of features (see C) but having a language that has tons of features but limits you on how to use this features (see D) is super annoying.
Now, I won't tell you how to design them, that's up to you to design but like I said in another "issue", something like how Rust does it would be awesome (but very hard to implement and maintain). Of course when that times comes, you can ask for our opinion but I personally trust that you will make something amazing that we will all love and you will at least read and consider some of the stuff I said. And of course I want to support and help a language with any way I can (even if it's a little) but of course this means spending my free time (for example this post I'm writing here) and I'm more than happy to do that for a language that the maintainers/developers are willing to at least listen my opinions and consider challenging their views and opinions (something that D developers don't seem to care to do). And this is why I love Vox so much and why I keep a close eye one it. I know that my time is spent in a place that deserves it and libvox will be my first (well excluding bug reports and posts like this if you count these as contributions with some way) and probably biggest contribution in the language and the community. And trust me, listening the community can only have positive results and I'm glad you are smart and kind and you understand that.
Anyway sorry for this big post but I didn't wrote for some times and I'm exited to be active here again! Read and take this post they way you feel. I would love to hear you opinion on my thoughts and what I've said if of course you want and have something to see. If not, I wish you a happy new year and I'll see you around!
Beta Was this translation helpful? Give feedback.
All reactions