Comments (4)
There's also go generate
to consider.
from mathgl.
That's coming in 1.4, right? I'm not too familiar with it, but the proposal I read simply allowed it to run arbitrary user-written code generation scripts, right? So doing this would still be necessary.
from mathgl.
Yes, go generate
is just a standard way for Go packages to run some commands to update their source code.
It's nice because it's a standard that's easy to follow and makes contributing to various Go packages easier. You know it's always go generate
, rather than make
or update_code.sh
or run_regen
or something else custom and non-standard.
See here for an example of replacing a bash file with go generate
directives: gopherjs/websocket@c80adc1.
from mathgl.
I tried to rewrite genprog using text/template
. Only vectors for now. Here is the result:
alexvasi@1ed7256
The main idea was to place all crucial information directly in the template and not in the program that generates code. I know, I could have passed meta info about types and functions to template. Or I could have used sub-templates for each function for example. In the end I decided against it. Template almost looks like a go code, if you squint hard enough. And that's a good thing, I guess. Except maybe there will be float32/64
flag later.
First of all it works. It is a zero-diff change... well, not actually. The order of functions in vector.go
is different now. It takes 10 or so additional lines in template to make the order the same. I dumped them. But that's how I tested new generator.
Here is some caveats:
text/template
is sloppy with whitespaces. I abusedgofmt
and it's called after template rendering.- I changed template separators from
{{
to<<
. It is too many curly brackets in go code already. - The readability of
vector.tpl
is not perfect. - Broken diff. It is hard to validate new generator with changed functions order. I should add some tests for each vector function to
vec_test.go
anyway.
from mathgl.
Related Issues (20)
- Error while trying to get library: undefined: sync.Pool HOT 5
- Usage with OpenGL HOT 4
- Matrix multiplication MulNx1 is incorrect HOT 2
- FloatEqualThreshhold broken ? HOT 6
- how to convert glm to mgl32? HOT 7
- default Epsilon and MinNormal same for both mathgl32 and mathgl64 HOT 4
- Possible copy & paste errors in tests HOT 2
- mgl32.Project lacks perspective divide HOT 1
- Request for a "Get Started" Tutorial HOT 2
- Incorrect coordinate mapping in ScreenToGLCoords and GLToScreenCoords. HOT 2
- possible error in BezierCurve2D()? HOT 2
- Go modules-compatible version tags HOT 10
- Vulkan compatibility HOT 4
- Package broken with Go 1.13 HOT 3
- Performance of basic vector math operations could be up to a 100 times faster. HOT 9
- `mgl64.Round(0, 2)` returns `-0` HOT 1
- No glm::translate and glm::scale? HOT 1
- mgl64.Vec2 does not support indexing
- Add common method for number of colums and rows HOT 1
- Add Scale() method HOT 1
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 mathgl.