p0nce / d-idioms Goto Github PK
View Code? Open in Web Editor NEW"Effective D" without the haircut.
Home Page: http://p0nce.github.io/d-idioms/
"Effective D" without the haircut.
Home Page: http://p0nce.github.io/d-idioms/
Some lines about the .capacity property
a++ is rewritten ++a if the result isn't used.
A little known feature
http://dlang.org/template.html
It seems way too optimistic to use >= anywhere in a DUB file. I'd like to write about it.
With cast(void*)object as user-data.
Need copypasta code
aa.get(key, default)
thanks yazd.
..d-idioms> dub
Building dmarkdown 0.2.0 configuration "library", build type debug.
Running dmd...
C:\Users\Dmitry\AppData\Roaming\dub\packages\dmarkdown-.2.0\source\dmarkdown\markdown.d(275): Error: no property 'joiner' for type 'Take!(Repeat!string)'
C:\Users\Dmitry\AppData\Roaming\dub\packages\dmarkdown-.2.0\source\dmarkdown\markdown.d(278): Error: no property 'map' for type 'Block[]'
FAIL C:\Users\Dmitry\AppData\Roaming\dub\packages\dmarkdown-0.2.0.dub\build\library-debug-windows-x86-dmd_2067-1564E97DABD8A03ACA3F1B08A8738B6E\ dmarkdown staticLibrary
Error executing command run: dmd failed with exit code 1.
https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/internal/meta/codegen.d#L272
Ensure a string mixin encodes the right type of function
Looks like a way to throw in @nogc code.
ubyte[__traits(classInstanceSize, YourClass)] from This week in D
It's on the dlang.org site but I've never stumbled upon it previously.
What they are, what they eat
this is too weird and useful to go down unnoticed: http://forum.dlang.org/thread/[email protected]#post-kwggroyzniavchsdqtka:40forum.dlang.org
XP reports say it's problematic.
Unlike C and C++
----
key in aa ? aa[key] : ValueType.init;
----
instead of
----
auto ptr = key in aa;
ptr ? *ptr : ValueType.init;
----`
TODO Some Phobos things are better be highlighted a bit
enforce
Unqual
Like version(assert)
http://p0nce.github.io/d-idioms/#Optimal-AA-lookup has mispelled doesn't as doens't in "The .get builtin property can also be used. It provides a default value when the key doens't exist"
We keep hearing that the GC makes soft real-time impossible, that is false.
Almost a secret feature, need more awareness
It's not clear to everybody, also function signatures with static arrays look the same as in C but have different semantics.
I think the last sentence here is wrong, or at least wrong by omission.
When to use and get the maximum value out of @disable this(this)
.
Which implies I know it.
This is a common need when actually using @nogc
Not everyone know about package.d or public import
If i am not the only one who needs to look up this pattern everytime again this idiom maybe useful for others:
auto removeElement(R,N)(R _haystack, N _needle){
import std.algorithm:countUntil,remove;
auto index = _haystack.countUntil(_needle);
return (index != -1) ? _haystack.remove(index) : _haystack;
}
usage:
auto arr = [1,5,10];
arr = arr.removeElement(5);
assert(arr == [1,10]);
When to use it, what does it eat.
A detailed description of the traps associated with class destructors would be right:
Walter explained this many times, and I feel this is indeed very important.
Writing a dub.json file fast is useful from times to times. The fastest I've found is:
{
"name": "program_name"
}
then have a file source/main.d
Useful whenever using range, could be in Phobos Gems.
I agree with that
http://forum.dlang.org/post/[email protected]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.