Git Product home page Git Product logo

d-idioms's People

Contributors

bbasile avatar bubnenkoff avatar dgame avatar dkorpel avatar lesderid avatar mathias-lang-sociomantic avatar ntrel avatar p0nce avatar pbackus avatar petarkirov avatar schveiguy avatar veelo avatar yannick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

d-idioms's Issues

Never use >=

It seems way too optimistic to use >= anywhere in a DUB file. I'd like to write about it.

Can't build

..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.

Optimal AA lookup

----
key in aa ? aa[key] : ValueType.init;
----
instead of
----
auto ptr = key in aa;
ptr ? *ptr : ValueType.init;
----`

Phobos must-know

TODO Some Phobos things are better be highlighted a bit
enforce
Unqual

@disable this(this);

When to use and get the maximum value out of @disable this(this).
Which implies I know it.

remove element from dynamic array

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]);

Warning about class destructors

A detailed description of the traps associated with class destructors would be right:

  • no allocation
  • could be called by the GC, or not
  • don't rely on members, etc

Smallest possible dub.json

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

.array

Useful whenever using range, could be in Phobos Gems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.