Comments (4)
There is a side effect to this though:
This would, very likely, silently compile if something is missing. And then panic at runtime.
The other approach, while being more space-consuming, will fail at compilation time, making it obvious immediately, that this will cause issues.
Especially in more complex applications, you want to get an error as soon as you can, so if you can make the compiler throw an error instead of the runtime, the error will be detected earlier.
The user of the library can safeguard this by adding in the appropriate
glib.{Minor,Major}Version checks at runtime, which will sidestep all the build
tag troubles.
While this would alleviate the issue somewhat, there is still a problem: The library user needs to keep track of every single call they use, and which minimum version that requires. Not sure about others, but I tend not to remember which specific version something was introduced in.
The "build tag trouble", while annoying (*), allows us to forcibly set a minimum required version, checked at compile time. This way we, as developers, get feedback from the compiler as soon as we messed up and used a function which is not available yet in our minimum version - regardless of which version we are developing with (which is in many cases NOT the minimum version supported by the application).
(*) => if we keep in mind that deprecated functions should not be removed from compilation in later versions, for obvious reasons. And if you silence the -Wdeprecated
warnings it does get better.
from gotk4.
This would, very likely, silently compile if something is missing. And then panic at runtime.
This is intended; it allows the programmer to code in optional function calls that are only called when the program is running on a newer version. An example of this was the insert-hyphens
property in Pango where certain distros were too old to have them.
Especially in more complex applications, you want to get an error as soon as you can, so if you can make the compiler throw an error instead of the runtime, the error will be detected earlier.
It has its cases. This isn't necessarily one of them.
While this would alleviate the issue somewhat, there is still a problem: The library user needs to keep track of every single call they use, and which minimum version that requires.
Yes, this is true. Most programmers won't care enough, and the program will likely crash once it hits that call. This is still a more avoidable problem than having it not build at all, though. One can open an issue to ask for the proper checks instead of telling them to give up.
The "build tag trouble", while annoying (*), allows us to forcibly set a minimum required version, checked at compile time. This way we, as developers, get feedback from the compiler as soon as we messed up and used a function which is not available yet in our minimum version - regardless of which version we are developing with (which is in many cases NOT the minimum version supported by the application).
This is really hard to do properly, both for the programmer and the code generator. The code generation details are mostly implementation-specific so I'll spare you that, but just making multiple files for some tiny one-liner function calls is already a lot of work for the programmer when a simple version check does the job.
Not to mention, package maintainers will have to update the package's build tags every time the upstream GTK package gets updated, which not only is a lot more work, but might also randomly break the package for users who don't always do a full system upgrade. With a simple runtime version check, that doesn't really happen.
from gotk4.
I understand you point of view, not having to worry about those tags is certainly a benefit.
There is one alternative solution I can think of.
The main purpose of my question is the error detection at an early point. I assume it would be possible for the generator to provide a list of symbols and when they were introduced - or a small additional tool based on the gir
package could be built.
Then, using go/parser
or similar, implement a CI tool to check for symbols in the source code which are below or above a certain GTK/Glib/etc release. Unless explicitly specified, this would be the version of the library currently available on the system.
This way both use cases would be possible: Easier compilation without build tags, AND early, static detection of issues with the library version.
What do you think?
from gotk4.
I think that sounds really complicated to implement. I'm not sure if I should really attempt that.
from gotk4.
Related Issues (20)
- Why go4.org/unsafe/assume-no-moving-gc ? HOT 4
- gir-generate failed to decode gir XML HOT 4
- Gstreamer bindings HOT 17
- Generator Workflow HOT 2
- Unusable GtkBuilderCScope API
- Memory is not freed when destroying Window HOT 1
- `DropTarget` panics when calling the `"drop"` signal handler HOT 10
- Bring back Unref methods
- Switch intern to KarpelesLab/weak
- why build time so slow? HOT 1
- run gtk4/simple get error
- Composite templates HOT 2
- SearchEntry does not appear to implement Editable interface correctly HOT 3
- Support binding Go objects to GObjects with `GObject.set_qdata`
- How to use GTK 4 GridView with gio.ListStore and gtk.BuilderListItemFactory HOT 2
- GTK Assertion Fails calling NewConstraint HOT 3
- gotk4 ApplicationWindow does not show after Hide()
- ASSUME_NO_MOVING_GC_UNSAFE_RISK_IT_WITH HOT 2
- Video Streaming HOT 26
- Custom glib.LogSetWriter HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotk4.