Re: core.sys.posix.setjmp unavailable for OS X?
On Tue, Jan 16, 2018 at 08:29:57AM +0100, Jacob Carlborg via Digitalmars-d-learn wrote: > On 2018-01-16 08:29, Jacob Carlborg wrote: > > > They're used to implement Objective-C exceptions on macOS 32bit and > > iOS. > > Forgot the second part: > > ... so I assume that means it works. [...] So we should add that to druntime, then. T -- MSDOS = MicroSoft's Denial Of Service
Re: core.sys.posix.setjmp unavailable for OS X?
On 2018-01-16 08:29, Jacob Carlborg wrote: They're used to implement Objective-C exceptions on macOS 32bit and iOS. Forgot the second part: ... so I assume that means it works. -- /Jacob Carlborg
Re: core.sys.posix.setjmp unavailable for OS X?
On 2018-01-15 20:37, H. S. Teoh wrote: It's probably just a matter of adding the appropriate prototypes / declarations to druntime. Provided that they actually work as advertised, of course. They're used to implement Objective-C exceptions on macOS 32bit and iOS. -- /Jacob Carlborg
[Issue 16017] package functions show up in std.experimental.allocator.common docs
https://issues.dlang.org/show_bug.cgi?id=16017 --- Comment #3 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/639c07e9428df844bb21adb8007503aa1e33b9b2 Fix Issue 16017 - package functions show up in std.experimental.allocator.common docs https://github.com/dlang/phobos/commit/d10a9da36b273c57308b52b92ca7a6aefe9b37f0 Merge pull request #6005 from wilzbach/fix-16017 --
[Issue 17440] Nullable.nullify() resets referenced object
https://issues.dlang.org/show_bug.cgi?id=17440 --- Comment #12 from hst...@quickfur.ath.cx --- I think you misunderstood my comment. I meant that one way to fix this bug is to change Nullable, or at least the overload that takes a single type parameter, so that it does not instantiate for reference types, or redirects the instantiation to Nullable!(T, null), so that when you call .nullify on it, it will just set the reference to null instead of attempting to destroy the object by calling .destroy on it. It really does not make sense to use Nullable!T, as currently implemented, for a class type T, since making that means there will be *two* null states, one with .nullify / .isNull, and the other with `= null` and `is null`, and the two null states will not be equivalent. That will only lead to more confusion. The fact that Nullable!T's dtor calls .destroy is further proof that the original intent was to use it with by-value types, not with class references. I'd say either the docs should recommend using Nullable!(T, null) for class types T, or else Nullable!T in that case should just internally redirect to Nullable!(T, null). --
Re: [theory] What is a type?
On Monday, 15 January 2018 at 20:46:19 UTC, Ali wrote: If you want to learns the ins and outs of types, this books comes highly recommended https://www.cis.upenn.edu/~bcpierce/tapl/ +1, TAPL is a must read for anyone in CS, I believe. Also recommended: "Type Theory & Functional Programming" by Simon Thompson, "Practical Foundations for Programming Languages" by Robert Harper and his and his colleagues lectures here: https://www.cs.uoregon.edu/research/summerschool/archives.html Many programmers remain unaware that there is a discipline called Type Theory, as part of math in general, it predates all electronic computers and it's still very relevant today. Anyone dabbling into compilers and programming language theory should learn the basics of type theory, proof theory and some category theory, these three are very much connected and talk about basically the same constructions from different angles (see Curry-Howard correspondence and "computational trinitarianism"). It's ridiculous how many programmers only learn about types from books on C++ or MSDN, get very vague ideas about them and never learn any actual PLT. Of course type is not a set of values, or any other set, not at all.
Re: Beta 2.078.1
On 01/16/2018 06:59 AM, Martin Nowak wrote: > Lots of useful fixes, most prominently dub now timeouts and uses one > of the mirrors when code.dlang.org has connection issues. https://github.com/dlang/dub/pull/1338
Beta 2.078.1
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 First beta for the 2.078.1 patch release. Lots of useful fixes, most prominently dub now timeouts and uses one of the mirrors when code.dlang.org has connection issues. http://dlang.org/download.html#dmd_beta http://dlang.org/changelog/2.078.1.html Please report any bugs at https://issues.dlang.org - -Martin -BEGIN PGP SIGNATURE- iQIzBAEBCgAdFiEEpzRNrTw0HqEtE8TmsnOBFhK7GTkFAlpdlLQACgkQsnOBFhK7 GTnaeg/8DnAsPv76MFeiZVgDvZlhKB7teuZNPxpbOyf+2y4k+IWVkpfaqhp9wkID UNNLaOG3u5eXA8EUaUT1Tlj3vUM/DUq/MRRz9e1LHkmOQCsdxOM8ozlCoRe6cxky 4NnYvWKYC36vzf2By/nCdPPMVbJJZnXoDPxbYR6So4kI+HZ9kqPnWWkc4zP0Tpb/ +0EEDyHTJ1xSqTJDSwC2nhFW8Gp+Bct6UBidC8sXyzETUlKAV/0BJzO68UGQeErZ 6ui8lr/lbbwtXzv+3T2c1qU46lNyRHBFtwidnt8S9RETCsiUm1KCxYKsZnpVznvR wALTvItaxJKv7w8mgpCRoAOhIWdCBq7odnQvblDxOF6GiuFCnoH20g9Pmj2yOJi5 LfsF/8WWHsXFTtLC8pgCmGCIfqRzZzwXYTWaQouj/VAacH/K2UR6xs5uuT8Fud/z gbEj2LUZaL+NLt3VdaRz8zuUz67+AxmR1ZvYStqawjBoHbbmn74qVG5qStaMcSnK RKFi44CSLAnCwrQaOwJ2XgeCOFTsOEvv/plfkJnATLSwDIC0CMCIFiKGPQoNO1Vo H++9YAACF+47AAGNDJR9wlvObJxWK4udoiMolw/MvRrWdA+hSVzXv4A2fWv6F+tP HGgz1Vcydqnj44+srTMBp3+I88M+/xnyC/WLi7L4knjFyQi2c8s= =aODt -END PGP SIGNATURE-
[Issue 18193] module config is in file 'rt/config.d' which cannot be read
https://issues.dlang.org/show_bug.cgi?id=18193 --- Comment #3 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/10afa6944bb3ac479cbcabc5499a86136907b95f Fix issue 18193 - module config is in file 'rt/config.d' which cannot be read (edit) https://github.com/dlang/druntime/commit/105d4a5ca279316665b3b796bf5ca7d249595caf Add test to the bug 18193 --
[Issue 13742] undefined reference to __coverage
https://issues.dlang.org/show_bug.cgi?id=13742 --- Comment #8 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/69e7bd18892df18f682906916bf8c8ad87fb30e5 fix Issue 13742 - undefined reference to __coverage - Nested template functions may reference coverage symbols of other modules. Those coverage symbols are either still `null` or already `symbol_reset`, in the former case coverage instrumentation is silently skipped, in the later case the linker will cause an error. This is because the current object file ends up with two `__coverage` symbols, one local BSS symbols and an undefined external symbol (for the other module's coverage). - Fixed by mangling the symbols as _D3pkg3mod__coverageZ (similar to __ModuleInfoZ) and making them global. - Ideally the symbols would use -visibility=hidden, but that ELF backend feature isn't yet accessible from glue.d. - This does not fix missing coverage when the referenced module hasn't yet been codegen'ed (e.g. because it follows on the command line or is part of another separate compilation). Using weak linkage to make this heuristically work would incurr some overhead for the coverage instrumentation. Unconditionally referencing coverage info OTOH might be too excessive, e.g. when the template function is in phobos, which would require to recompile phobos with -cov for successful linking. https://github.com/dlang/dmd/commit/0cb16110c307b608034d49289e2a650e7d7d7dd8 Merge pull request #7654 from MartinNowak/fix13742 fix Issue 13742 - undefined reference to __coverage --
[Issue 13742] undefined reference to __coverage
https://issues.dlang.org/show_bug.cgi?id=13742 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
[Issue 18233] building with -m64 doesn't work with sc.ini from the zip distribution and VS2017
https://issues.dlang.org/show_bug.cgi?id=18233 --- Comment #3 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/e9b2864e1b0f59415045533423c64447b3e468aa fix issue 18233 - building with -m64 doesn't work with sc.ini from the zip distribution and VS2017 https://github.com/dlang/dmd/commit/a81d286dd69dafb6d8c2605804602b19e98634dd Merge pull request #7686 from rainers/cleanup_ini --
[Issue 18111] unittests get different names depending on how the files are passed to dmd
https://issues.dlang.org/show_bug.cgi?id=18111 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3b551d3ce6d9d654ba64c11ce0c7c926b1197aa0 Fix issue 18111: use fully qualified name for modules in unittest names https://github.com/dlang/dmd/commit/e6038789f09d629bc2401569be88689dee665e3f Merge pull request #7496 from atilaneves/fix_issue_18111 --
Re: I want to transmit the class name and the member name in the method
On Monday, 15 January 2018 at 15:28:19 UTC, Martin Nowak wrote: More concise stuff is possible with heavy compile-time trickery (https://dpaste.dzfl.pl/cd375ac594cf) without incurring dreaded 1+N queries or even any unnecessary SELECT fields. foreach (u; db.select!User.where!"NOT can_overdraw") { sendMail(u.name, u.mail.addr, u.lendings // no 1+N here .where!"DATEDIFF(NOW(), end_date) >= 7 AND book.amount < 20") .map!(l => l.book.Reminder)); // client side range API } This has become even more of a challenge since we plan to make it a @safe @nogc poster child. If anyone wants to help with this project please contact me. At the moment reworked @safe @nogc database drivers would be most helpful. I'll soon publish a small RC, Uniq, Weak library. Unbuffered IO foundations are already here https://github.com/MartinNowak/io, but not yet practically proven, and still lacking vibe-core scheduler/eventcore integration. If someone wants to see this happen, but doesn't have enough time to contribute, you could help to crowdfund this work, so I could afford to spent more time working on this. Get in contact with us for more details. https://dlang.org/donate.html
Re: Does it have an http2 server/client lib like in golang?
On Monday, 15 January 2018 at 18:07:24 UTC, Cergoo wrote: subj WIP but a bit stalled. https://github.com/vibe-d/vibe.d/tree/http2-botan-cleanup Unless you really need server-push of assets, HTTP/2 on a reverse proxy gets you the same performance benefits as well.
[Issue 17440] Nullable.nullify() resets referenced object
https://issues.dlang.org/show_bug.cgi?id=17440 --- Comment #11 from Marenz--- I can only repeat what I said before. The principle of the least surprise should apply. No one expects their object to be destroyed when a reference to it is set to null, be it through .nullify(); or through = null; It's not difficult to fix and it saves lots of people debugging time, figuring out why the hell their object is gone. Note that already two persons have stumbled over this AND have reported it. God knows how many more this happened to who haven't given this valuable feedback. --
class initialization
in C# you can initilizate the class members like this: var foo = new Foo { a = 1, b = 2 }; I found something similar to structs in D: myStruct S = {a:1, b:2}; But can't figure out if D does have that for classes.
[Issue 18242] DMD Segmentation fault.
https://issues.dlang.org/show_bug.cgi?id=18242 --- Comment #1 from changlon--- /** * This code is based on Adam D. Ruppe $(LINK2 http://arsdnet.net/dcode/minimal.zip minimal.zip). * Probably Boost licensed */ module object; /// All D class objects inherit from Object. class Object { } /// The base class of all thrown objects. class Throwable { } int _d_run_main() { int result = void; try result = 1; catch(Throwable e) _d_print_throwable; } == dmd -defaultlib= -debuglib= object.d --
Re: Undefined Reference to OpenSSL EVP functions
On Tuesday, 16 January 2018 at 00:52:09 UTC, Chris wrote: I am trying to hook up OpenSSL to a dlang project I'm working on, but I have hit a problem when trying to link. I currently get the following linking error: undefined reference to `EVP_CIPHER_CTX_init' I have made sure to include the module wrapping the c headers import deimos.openssl.evp; And I have made sure that I am linking to "libcrypto" and "libssl" in my "dub.json" file. I have even pointed the linker to my "/usr/lib" folder And I made sure that those libraries are installed on my system in "/usr/lib" libcrypto.o libssl.o Here is the code that I am trying to run: import deimos.openssl.evp void main() { EVP_CIPHER_CTX *ctx; EVP_CIPHER_CTX_init(ctx); } Here is the full verbose output of dub: https://pastebin.com/raw/4FnhCyr2 Here is my full dub.json file: https://pastebin.com/raw/1Z3WGBET Any help would be greatly appreciated! Thank you so much! Hi Everyone, this is not an error in D, or the OpenSSL wrapper code it's just me not reading the OpenSSL man pages... EVP_CIPHER_CTX_init is not longer the way to create the context in 1.1.0 - It has been replaced by: EVP_CIPHER_CTX *ctx; ctx = EVP_CIPHER_CTX_new() RTFM...
Trait compiles
Hello, is there anyway to do something like this: mixin template foo( exp) { static if(__traits(compiles, exp))exp; } Thanks :)
[Issue 18242] New: DMD Segmentation fault.
https://issues.dlang.org/show_bug.cgi?id=18242 Issue ID: 18242 Summary: DMD Segmentation fault. Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: blocker Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: chang...@gmail.com I run into DMD segmentation fault under linux and Mac OSX, not test windows yet. DMD v2.078.0-401-g716303a41-dirty DEBUG Program received signal SIGSEGV, Segmentation fault. 0x558c694e in _D3dmd12statementsem13catchSemanticFCQBj9statement5CatchPSQCe6dscope5ScopeZv (sc=0x75f611e0, c=0x77efb550) at dmd/statementsem.d:4038 4038 cd != ClassDeclaration.exception && !ClassDeclaration.exception.isBaseOf(cd, null) && The demangle symbol is: void dmd.statementsem.catchSemantic(dmd.statement.Catch, dmd.dscope.Scope*) The code is rather big and I can not made it work with dustmite. --
Re: TSV Utilities release with LTO and PGO enabled
On Tuesday, 16 January 2018 at 00:19:24 UTC, Martin Nowak wrote: On Sunday, 14 January 2018 at 23:18:42 UTC, Jon Degenhardt wrote: Combined, LTO and PGO resulted in performance improvements greater than 25% on three of my standard six benchmarks, and five of the six improved at least 8%. Yay, I'm usually seeing double digit improvements for PGO alone, and single digit improvements for LTO. Meaning PGO has more effect even though LTO seems to be the more hyped one. Have you bothered benchmarking them separately? Last spring I made a few quick tests of both separately. That was just against the app code, without druntime/phobos. Saw some benefit from LTO, mainly one of the tools, and not much from PGO. More recently I tried LTO standalone and LTO plus PGO, both against app code and druntime/phobos, but not PGO standalone. The LTO benchmarks are here: https://github.com/eBay/tsv-utils-dlang/blob/master/docs/dlang-meetup-14dec2017.pdf. I've haven't published the LTO + PGO benchmarks. The takeaway from my tests is that LTO and PGO will benefit different apps differently, perhaps in ways not easily predicted. One of my tools benefited primarily from PGO, two primarily from LTO, and one materially from both. So, it is worth trying both. For both, the big win was from optimizing across app code and libs (druntime/phobos in my case). It'd be interesting to see if other apps see similar behavior, either with phobos/druntime or other libraries, perhaps libraries from dub dependencies.
Re: Phobos bindings
On 1/14/18 1:17 PM, Temtaime wrote: Phobos comes with zlib, curl and sqlite bindings. Zlib sources come with phobos, so there's no need to build and link with it separately. Why there's no curl and sqlite sources ? For example sqlite comes as 1 file. I think we can add it too, isn't it ? The inclusion of etc in general has been considered a mistake. Since they were added, dub has obviated any need to include such things in Phobos. In fact there have been efforts to remove them from Phobos (https://github.com/dlang/phobos/pull/4283). That being said, zlib is quite a static library. The others are actively developed, and we shouldn't need to keep updating all our sources when the external dependencies change. -Steve
Undefined Reference to OpenSSL EVP functions
I am trying to hook up OpenSSL to a dlang project I'm working on, but I have hit a problem when trying to link. I currently get the following linking error: undefined reference to `EVP_CIPHER_CTX_init' I have made sure to include the module wrapping the c headers import deimos.openssl.evp; And I have made sure that I am linking to "libcrypto" and "libssl" in my "dub.json" file. I have even pointed the linker to my "/usr/lib" folder And I made sure that those libraries are installed on my system in "/usr/lib" libcrypto.o libssl.o Here is the code that I am trying to run: import deimos.openssl.evp void main() { EVP_CIPHER_CTX *ctx; EVP_CIPHER_CTX_init(ctx); } Here is the full verbose output of dub: https://pastebin.com/raw/4FnhCyr2 Here is my full dub.json file: https://pastebin.com/raw/1Z3WGBET Any help would be greatly appreciated! Thank you so much!
Re: Proposed Phobos equivalent of wcswidth()
On Monday, 15 January 2018 at 13:34:09 UTC, Jack Stouffer wrote: On Saturday, 13 January 2018 at 17:26:52 UTC, H. S. Teoh wrote: ... Thanks for taking the time to do this. And now the obligatory bikeshed: what should the Phobos equivalent of wcswidth be called? std.utf.displayWidth std.utf.bikeshed Never heard that phrase before. Nice one :)
Re: TSV Utilities release with LTO and PGO enabled
On Sunday, 14 January 2018 at 23:18:42 UTC, Jon Degenhardt wrote: Combined, LTO and PGO resulted in performance improvements greater than 25% on three of my standard six benchmarks, and five of the six improved at least 8%. Yay, I'm usually seeing double digit improvements for PGO alone, and single digit improvements for LTO. Meaning PGO has more effect even though LTO seems to be the more hyped one. Have you bothered benchmarking them separately?
[Issue 18241] Missing characters from std.uni.unicode.Default_Ignorable_Code_Point
https://issues.dlang.org/show_bug.cgi?id=18241 hst...@quickfur.ath.cx changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |INVALID --- Comment #2 from hst...@quickfur.ath.cx --- Actually, nevermind this bug. The file at http://www.unicode.org/L2/L2002/02368-default-ignorable.pdf is outdated; std.uni actually does obey the latest standard as given in ftp://ftp.unicode.org/Public/UNIDATA/DerivedCoreProperties.txt. --
Re: How to run vibe.d web app in XAMPP server ?
On Monday, 15 January 2018 at 06:22:13 UTC, Jayam wrote: In our production server, we have only XAMPP for use to deploy web app and mysql combinedly? Is there any way how to deploy the vibe.d web app into XAMPP ? To use Apache to proxy requests to your D app do something along these lines: Configure a Virtual Host for use with the application: sudo vim /etc/apache2/sites-available/yoursite.conf using the following content: ServerAdmin webmas...@example.com ServerName example.com ServerAlias www.example.com ErrorLog /var/log/apache2/yoursite-error.log CustomLog /var/log/apache2/yoursite-access.log common ProxyRequests off ProxyPreserveHost off ProxyPass / http://127.0.0.1:8080 ProxyPassReverse / http://127.0.0.1:8080 Then make sure to enable the relevant mods and your site sudo a2enmod proxy proxy_http sudo a2ensite yoursite Verfiy the Apache config with apachectl configtest then restart: sudo systemctl restart apache2
[Issue 18241] Missing characters from std.uni.unicode.Default_Ignorable_Code_Point
https://issues.dlang.org/show_bug.cgi?id=18241 --- Comment #1 from hst...@quickfur.ath.cx --- Actually, strike U+06DD and U+070F from the list. These are explicitly specified by TR 44 as being exceptional cases that should NOT be ignored, even though they belong to the Cf category. --
[Issue 18241] New: Missing characters from std.uni.unicode.Default_Ignorable_Code_Point
https://issues.dlang.org/show_bug.cgi?id=18241 Issue ID: 18241 Summary: Missing characters from std.uni.unicode.Default_Ignorable_Code_Point Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: hst...@quickfur.ath.cx The set returned by unicode.Default_Ignorable_Code_Point is missing some characters listed in: http://www.unicode.org/L2/L2002/02368-default-ignorable.pdf where Default_Ignorable_Code_Point is defined as: Other_Default_Ignorable_Code_Point + (Cf + Cc + Cs - White_Space) While characters in Other_Default_Ignorable_Code_Point seem to be included correctly, two characters in Cf appear to be missing from the set: - U+06DD - U+070F Furthermore, characters in (Cc - White_Space) are also missing: - U+ to U+0008 - U+000E to U+001F (See also: PR #5, referencing the Unicode Standard section 5.22.) Not sure if this is because these missing characters were added in a later Unicode standard than was originally implemented in std.uni. --
Re: Tuple DIP - tuple unification with arrays and structs
On 1/14/2018 6:55 AM, Q. Schroll wrote: How is (1, 2) different from [1, 2] (static array)? It's a very good question. It's corollary is how is (1, 2) different from struct S { int a, b; } It does turn out that int[2] is structurally (!) the same as struct S. This is a property I've taken some pains to ensure stays valid, and it has turned out to be nicely useful. But consider: S foo(char a, char b); t = ('a', 'b'); foo(t); // equivalent to foo('a', 'b') That works. But: S s = {'a', 'b' }; foo(s); // Does not work It does not work is because s as a parameter has a distinctly different ABI than (char, char). The former consumes an int sized parameter, the latter two int sized parameters. A similar issue exists with the return value. So far, the issue of unification of tuples with arrays (and structs) has defeated me because of the fundamental structural differences in the ABI which we are stuck with.
Re: Tuple DIP
On 1/14/2018 10:17 AM, Timon Gehr wrote: It's inherited from C, where all struct instances have size at least 1. (Such that each of them has a distinct address.) There are some peculiarities with that, like with multiple inheritance sometimes the size really is zero :-)
Re: run.dlang.io can now display ASM + AST + IR
On Sunday, 14 January 2018 at 04:18:41 UTC, Seb wrote: 3) IR (LDC only) https://run.dlang.io/is/BOTNDf Thanks Seb. I particularly like this feature. After a quick glance, the debuginfos (-g) seem to be needlessly enforced, bloating the IR. A colored output would be a nice improvement; there's a plugin for the google-code-prettify JS library [1], which wouldn't increase the server load. Maybe there's one for asm too. [1] https://gist.github.com/ndabas/2850418
Re: How to imporve D-translation of these Python list comprehensions ?
On 15.01.2018 20:05, xenon325 wrote: I think, most clear code would be with tripple `foreach`, so I'll go with that. But probably someone will come up with something better and range-ier. Suggestion are welcome! import std.stdio, std.algorithm, std.range, std.array, std.conv, std.json, std.typecons; auto aa(R)(R r){ typeof(r.front[1])[typeof(r.front[0])] a; foreach(x;r) a[x[0]] = x[1]; return a; } alias emap(alias a) = map!(x => a(x.expand)); void main(){ auto srv1 = [ "acs": ["ver": "1.2.3", "rev": "6f2260d"], "cms": ["ver": "4.5", "rev": "b17a67e"], "ots": ["ver": "6.7.80", "rev": "4f487d2"]]; auto srv2 = [ "acs": ["ver": "1.2.3", "rev": "6f2260d"], "cms": ["ver": "5.1", "rev": "2a56c53"], "vaa": ["ver":"0.7", "rev": "00852cb"]]; chain(srv1.keys, srv2.keys).sort.uniq .map!(k => chain(only(tuple("_name", k)), cartesianProduct(only("ver", "rev"), only(srv1, srv2).enumerate) .emap!((prop, srv) => tuple(text(prop, srv.index), srv.value.get(k, null).get(prop, ""))) ).aa).array.JSONValue.toPrettyString.writeln; }
Re: How to imporve D-translation of these Python list comprehensions ?
On 15.01.2018 22:51, Timon Gehr wrote: auto aa(R)(R r){ typeof(r.front[1])[typeof(r.front[0])] a; foreach(x;r) a[x[0]] = x[1]; return a; } Actually, better to use std.array.assocArray. import std.stdio, std.algorithm, std.range, std.array, std.conv, std.json, std.typecons; alias emap(alias a) = map!(x => a(x.expand)); void main(){ auto srv1 = [ "acs": ["ver": "1.2.3", "rev": "6f2260d"], "cms": ["ver": "4.5", "rev": "b17a67e"], "ots": ["ver": "6.7.80", "rev": "4f487d2"]]; auto srv2 = [ "acs": ["ver": "1.2.3", "rev": "6f2260d"], "cms": ["ver": "5.1", "rev": "2a56c53"], "vaa": ["ver": "0.7", "rev": "00852cb"]]; chain(srv1.keys, srv2.keys).sort.uniq .map!(k => chain(only(tuple("_name", k)), cartesianProduct(only("ver", "rev"), only(srv1, srv2).enumerate) .emap!((prop, srv) => tuple(text(prop, srv.index), srv.value.get(k, null).get(prop, ""))) ).assocArray).array.JSONValue.toPrettyString.writeln; }
Re: How to imporve D-translation of these Python list comprehensions ?
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote: I think, most clear code would be with tripple `foreach`, so I'll go with that. But probably someone will come up with something better and range-ier. I will admit clarity has suffered, but I like the brevity: import std.json : JSONValue; import std.array : array, assocArray; import std.range : enumerate, byPair; import std.algorithm : sort, joiner, map, uniq, each; import std.typecons : tuple; import std.conv : to; import std.stdio : writeln; unittest { immutable srv1 = ["acs": ["ver": "1.2.3", "rev": "6f2260d"], "cms": ["ver": "4.5", "rev": "b17a67e"], "ots": ["ver": "6.7.80", "rev": "4f487d2"]]; immutable srv2 = ["acs": ["ver": "1.2.3", "rev": "6f2260d"], "cms": ["ver": "5.1", "rev": "2a56c53"], "vaa": ["ver":"0.7", "rev": "00852cb"]]; immutable keys = ["rev", "ver"]; immutable srvs = [srv1, srv2]; alias aget = (name, key) => srvs.map!(s => s.get(name, [key:""])[key]); alias bget = (name, key) => aget(name, key).enumerate.map!(b => tuple(key~b.index.to!string, b.value)); alias merge = (aa1, aa2) => (aa2.byPair.each!(kv => aa1[kv.key] = kv.value), aa1); auto result = srvs .map!(s => s.byKey) .joiner .array .sort .uniq .map!(name => merge(keys.map!(key => bget(name, key)).joiner.assocArray, ["_name": name])) .array; writeln(JSONValue(result).toPrettyString()); } -- Simen
Re: Article: Fuzzing D code with LDC
On Sat, Jan 13, 2018 at 11:59:52PM +, Johan Engelen via Digitalmars-d-announce wrote: > It's been a work-in-progress for half a year, but finished now: > > http://johanengelen.github.io/ldc/2018/01/14/Fuzzing-with-LDC.html [...] It would be good to program custom fuzzers for Phobos modules, especially the ones with generic code like std.algorithm and std.range, a lot of which I suspect have unhandled edge cases and other such overlooked flaws. Fuzzing at this level will be harder than merely fuzzing with random data; as input we'd need higher-level objects like ranges of various types and by-reference / by-value semantics. And detecting problem cases may not be so easy (how to detect if, say, reduce() returned the wrong answer when the input is randomized?). T -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
[Issue 18240] core.stdc.wchar_ wmemset, etc. should be pure
https://issues.dlang.org/show_bug.cgi?id=18240 --- Comment #1 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/2bc68a917905faa89eb9b6458dc52b0cdf992ea4 Fix Issue 18240 - core.stdc.wchar_ wmemset, etc. should be pure Also regularize qualifiers to match core.stdc.string. https://github.com/dlang/druntime/commit/c5b2777dd05b676c001677a808a60d352d43e6a2 Merge pull request #2043 from n8sh/wmemset-pure Fix Issue 18240 - core.stdc.wchar_ wmemset, etc. should be pure merged-on-behalf-of: Iain Buclaw--
[Issue 17440] Nullable.nullify() resets referenced object
https://issues.dlang.org/show_bug.cgi?id=17440 --- Comment #10 from hst...@quickfur.ath.cx --- P.S. Actually, Nullable does have another overload that takes a null value to be used in lieu of a boolean flag. So conceivably, you could use Nullable!(T, null) instead of Nullable!T and you will have the requisite semantics. --
Re: How to imporve D-translation of these Python list comprehensions ?
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote: A workmate has recently shown this piece of code to show how nice Python is (we are mostly C and growing C++ shop): [...] Well if that is what they can do in Python I'd hate to see their C++! They have done a great job making Python code read like Perl. This looks like something you'd see in an assignment at uni; "Decipher this Python code and port to your language of choice" :)
Re: [theory] What is a type?
On Monday, 15 January 2018 at 19:25:16 UTC, H. S. Teoh wrote: At the most abstract level, a type is just a set. The members of the set represent what values that type can have. Hm, yes, like representing an ordered pair (a,b) as {{a},{a,b}}. But I think typing is more commonly viewed as a filter. So if you represent all values as sets, then the type would be a filter preventing certain combinations. It is a matter of perspective, constructive or not constructive. Kinda like synthesis, additive (combine sines) or subtractive (filter noise).
Re: [theory] What is a type?
On Sunday, 10 October 2010 at 12:28:32 UTC, Justin Johansson wrote: Now having hopefully described that a type is something that might well have multiple orthogonal aspects to its identity, how would one go about implementing a dynamic language with such a complex type system in D? I realize that this is a complex topic and that it might require better articulation than so far I have given. Nevertheless, thanks for all replies, Justin Johansson If you want to learns the ins and outs of types, this books comes highly recommended https://www.cis.upenn.edu/~bcpierce/tapl/
Re: [theory] What is a type?
On Sunday, 10 October 2010 at 12:28:32 UTC, Justin Johansson wrote: Specifically I have a problem in trying to implement a functional language translator in D. My target language has a rather non-conventional type system, in which, superficially at least, types can be described as being Cartesian in nature. That is, types in this system have two orthogonal dimensions: (1) classical data-type (e.g. boolean, number, string, object) and (2) Kleene cardinality (occurrences) with respect to (1). The axial origin of this Cartesian type-system correlates well with the concept of the "top" type (AKA "Unit" in Scala) and as the rather adhoc "void" type in many Algol-derived languages such as C/C++/Java/D. So along axis 1 we might broadly describe the classical data types as item, boolean, number, string, object where item is effectively either a superclass or variant of the other mentioned types. Along axis 2 we describe Kleene occurrences of 1 as may be passed contractually to a receiving function. These occurrences may be enumerated six-fold as: zeroOrMore zeroOrOne oneOrMore exactlyZero exactlyOne none Readers may see that, for example, zeroOrOne is a special case (perhaps a subclass?) of zeroOrMore. exactlyOne is a special case of both zeroOrOne and oneOrMore (sounds like multiple inheritance?). OTOH, exactlyZero is a special case of zeroOrOne, which, in turn, is a special case of zeroOrmore. none is a special case of all of the above and reflects the cardinality facet of the return type of a function that never returns (say as by throwing an exception). To make this type system even more enigmatic lets add a third dimension, taking the 2-D Cartesian type system model to a 3-D Spatial model, by imagining a further degree of freedom with respect to laziness of evaluation (AKA closure of arguments). Now having hopefully described that a type is something that might well have multiple orthogonal aspects to its identity, how would one go about implementing a dynamic language with such a complex type system in D? I realize that this is a complex topic and that it might require better articulation than so far I have given. Nevertheless, thanks for all replies, Justin Johansson Well, in D-speak you could imagine taking (perhaps arbitrarily) the first axis (basic data type) as the "skeleton" and attach various properties to it. For example: Int!(exactlyOne, eager) x = 42; Int!(zeroOrMore, lazy) y; readf("%d", ); auto foo = x+y; // What does this mean? What type is foo? You seem to have in mind a syntax for your type system but I'm not sure how you intend for the semantics to work. D's templates are really nice in that they allow you to express many properties of a term that are not "hard coded" into its type. So you can do stuff like: enum MinimizationTarget { programThroughput, GCThroughput, heapOverhead, pauseTimes, pauseFrequency, heapFragmentation, warmupTime } auto GarbageCollector(MinimizationTarget[] priorities = [])() { static if (priorities == []) return StopTheWorldMarkAndSweepGC(); else static if (priorities[0] == heapFragmentation) return copyingGC(); else static if (/* some boolean algebra condition on $priorities */) return GenerationalMarkAndSweepGC(); else /* etc. */ } auto myGC = GarbageCollector![pauseTimes, heapOverHead, programThroughput]; auto myGraph = Graph!(myGC, directed); which is pretty cool. :)
Re: How to imporve D-translation of these Python list comprehensions ?
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote: A workmate has recently shown this piece of code to show how nice Python is (we are mostly C and growing C++ shop): dd = [dict(_name=k, **{a + str(i): aget(d, k, a) for a in aa for i, d in enumerate([srv1, srv2])}) for k in sorted(kk)] This is the most terrible Python code I have ever seen. If you know Python, could you please unroll to more readable form? Suggestion are welcome! --- Alexander
[Issue 17440] Nullable.nullify() resets referenced object
https://issues.dlang.org/show_bug.cgi?id=17440 hst...@quickfur.ath.cx changed: What|Removed |Added CC||hst...@quickfur.ath.cx --- Comment #9 from hst...@quickfur.ath.cx --- But by-reference objects in D *already* have nullable semantics, i.e.: --- class C {} C c; assert(c is null); // c is null by default c = new C; assert(c !is null); c = null; // nullify assert(c is null); --- Of course the syntax is slightly different (direct use of null vs. .isNull / .nullify). But there's really no benefit to using Nullable with reference types in D. OTOH, if you're using generic code that expect a single API for nullable objects, perhaps the solution is to write an overload of Nullable that simply maps .isNull to `is null` and .nullify to `= null` when the wrapped type is a class. --
Re: Proposed Phobos equivalent of wcswidth()
On Sat, Jan 13, 2018 at 09:26:52AM -0800, H. S. Teoh via Digitalmars-d wrote: [...] > https://github.com/quickfur/strwidth [...] One thing I'm seeking help with, and this is mainly directed at Dmitry Olshansky but can be anyone here who knows the internal workings of std.uni well enough, is how to transform the Trie generated by the static ctor into compile-time TrieNode declarations. This is one blocker for my turning this code into a Phobos PR, because I don't want to incur the cost of initializing this trie at runtime. Also, on a related note, there exist nicer interfaces in std.uni for constructing Tries that map ranges of codepoints to non-boolean values, but none of these are available publicly. The current implementation in strwidth only uses the public API of std.uni, so the construction of the trie is pretty horrendous (looping over individual codepoints and creating an AA of individual codepoints -- including very large ranges like the entire Unicode plane 2). I wonder if some of these facilities should be made public so that user code that needs to construct codepoint tries that include large ranges of codepoints can do so more efficiently. T -- This sentence is false.
Re: [theory] What is a type?
On Monday, 15 January 2018 at 19:34:23 UTC, Ali Çehreli wrote: On 01/15/2018 10:58 AM, Jonathan Marler wrote: > On Sunday, 10 October 2010 at 12:28:32 UTC, Justin Johansson wrote: > I'm getting "nostalgia" from all the math terminology :) Just the date of the post you're responding to is sufficient for "nostalgia". ;) Ali Oh wow! I don't know why the form post was on the first page of my form thread. You think he still checks his thread every day to see if someone has responded? :)
Re: mysql-native: Prepared statements: Direction and future
On Mon, Jan 15, 2018 at 01:30:42PM -0500, Nick Sabalausky (Abscissa) via Digitalmars-d-announce wrote: > I've posted (what basically amounts to an article) about my current > thoughts on addressing Prepared's current downsides in the next > release (v2.0.0), as well as a little bit of future direction of the > lib. > > Anyone interested in mysql-native's prepared statements (especially > their interplay with connection pools) is encouraged to take a look > and share any thoughts: > > https://github.com/mysql-d/mysql-native/issues/95#issuecomment-357757013 A lot of what you discuss here is pertinent not only to mysql-native, but to (SQL) database bindings in general. I've been facing much the same questions in my own SQLite bindings, which are based on Adam Ruppe's sqlite.d. One of these days, we should draft up a "standard" API for SQL database bindings in D, so that implementations can benefit from a well thought out API design instead of rolling their own each time. T -- "If you're arguing, you're losing." -- Mike Thomas
Re: core.sys.posix.setjmp unavailable for OS X?
On Mon, Jan 15, 2018 at 07:06:42PM +, bpr via Digitalmars-d-learn wrote: > Is there a reason that it's unavailable on OS X when it works fine on > Linux? The functions exist on OS X, and it's easy enough to compile C > programs using setjmp there; but not D programs. I don't think I'm > getting a betterC experience on the Mac. [...] It's probably just a matter of adding the appropriate prototypes / declarations to druntime. Provided that they actually work as advertised, of course. There may be incompatibilities that I'm not aware of that would preclude it from being added to druntime. In any case, if druntime doesn't provide the right declarations, you *could* just declare them yourself with an extern(C). E.g.: extern(C) int setjmp(jmp_buf env); extern(C) void longjmp(jmp_buf env, int val); ... jmp_buf buf; int rc = setjmp(buf); if (rc == 0) { ... longjmp(buf, rc); } else { // handle error } You'll need to obtain your system's definition of jmp_buf, of course, and translate it into D appropriately. You can find it in the usual system include directories, like /usr/include or something along those lines. Most C structs can be copied verbatim into D and it would work. (Note that you'll need to find the *exact* declaration used; especially for structs, you may not be able to just use generic declarations given by the Posix spec, because if your OS has additional fields for internal use, you want to make sure those fields are declared properly, otherwise the struct will have the wrong size and you may get problems at runtime.) Better yet, once you figure out how to do it, submit a PR against druntime so that future users of your OS will benefit from it. ;-) T -- A program should be written to model the concepts of the task it performs rather than the physical world or a process because this maximizes the potential for it to be applied to tasks that are conceptually similar and, more important, to tasks that have not yet been conceived. -- Michael B. Allen
Re: [theory] What is a type?
On Mon, Jan 15, 2018 at 06:58:37PM +, Jonathan Marler via Digitalmars-d wrote: [...] > That being said, I don't think this model really get much closer to > answering the original question, "what is a type?". [...] At the most abstract level, a type is just a set. The members of the set represent what values that type can have. Operations on types are therefore simply operations on sets, which lets us bring in the entire mechanism of mathematical sets to elaborate upon the theory of types. A boolean, for example, is simply a 2-membered set B = {true, false}. A struct of two booleans is just the Cartesian product B x B. An array of booleans is simply the Kleene closure of B, i.e., the union of all Cartesian powers of B, usually denoted as B*. This abstract view disregards how a type is actually implemented, and merely considers its set of possible values. Under this model, you begin by describing the sets of possible values your program will work with. Then when you're ready to implement it, you decide on some kind of mapping to map the abstract sets to the physical types provided by the hardware. On a more practical level, the way I see a type is an *interpretation* imposed upon a series of zero or more bytes (or, if you want to drill down even deeper, bits). The same binary values can represent different types, depending on how you interpret them. Under this model, you proceed in the opposite direction: starting with an arbitrary sequence of bytes, you recursively build up interpretations of it until you arrive at the data structures that your program will operate on. The abstract view is useful when you're working within your problem domain: it allows you to phrase your algorithms and transformations directly in terms of the objects and operations you wish to work on. But it's not always so easy to map this abstract model onto the quirks of the hardware you have to work with. It's easy to think of trivial mappings, of course, but generally they will have pretty poor performance because they don't take advantage of the properties of the underlying hardware. Finding an *efficient* mapping that doesn't also break correctness can be quite challenging. The practical view is useful when you're building things from ground up, e.g., when you're building a compiler. It lets you build up types that can take advantage of the underlying hardware's properties, and also avoid or work around hardware quirks or weaknesses. It also allows you to reinterpret types creatively, that may allow you to achieve interesting effects (e.g., the data bytes output by the compiler can be reinterpreted as executable code by the CPU). However, types built up this way may not map nicely into your problem domain, and that forces your code to become convoluted in order to compensate for the impedance mismatch between the two. Correctness may also be compromised if the objects in your problem domain don't have a 1-to-1 fit with the hardware types (e.g., your calculator program might operate on integers in the mathematical sense of numbers that can be arbitrarily large, but the int type provided by the hardware is modulo some power of 2; so when values get too large, what your program thinks of as an integer no longer matches what the hardware implements, resulting in overflow/underflow bugs). Finding the sweet spot that balances the two is non-trivial, and is the subject of entire fields of research. :-D T -- The trouble with TCP jokes is that it's like hearing the same joke over and over.
Re: [theory] What is a type?
On 01/15/2018 10:58 AM, Jonathan Marler wrote: > On Sunday, 10 October 2010 at 12:28:32 UTC, Justin Johansson wrote: > I'm getting "nostalgia" from all the math terminology :) Just the date of the post you're responding to is sufficient for "nostalgia". ;) Ali
gRPC in D good idea for GSOC 2018?
I know a project where D could benefit from gRPC in D, which is not among the supported languages: https://grpc.io/docs/ Do you think gRPC support is worth adding to GSOC 2018 ideas? https://wiki.dlang.org/GSOC_2018_Ideas Ali
[Issue 17462] Order of base interfaces affects compiler behavior
https://issues.dlang.org/show_bug.cgi?id=17462 --- Comment #4 from Andrei Alexandrescu--- The following C++ equivalent does require the additional implementation (uncomment code to get it to compile): class Marker {}; class Foo { public: virtual void foo() = 0; }; class FooMarked : public Foo, public Marker {}; class MarkedFoo : public Marker, public Foo {}; class Base : public Foo { virtual void foo() {} }; class Derived1 : public Base, public FooMarked { //virtual void foo() {} }; class Derived2 : public Base, public MarkedFoo { //virtual void foo() {} }; int main() { auto d1 = new Derived1; auto d2 = new Derived2; } However, this other code, which arguably is closer in spirit, does work: class Marker {}; class Foo { public: virtual void foo() = 0; }; class FooMarked : virtual public Foo, public Marker {}; class MarkedFoo : public Marker, virtual public Foo {}; class Base : virtual public Foo { virtual void foo() {} }; class Derived1 : public Base, public FooMarked {}; class Derived2 : public Base, public MarkedFoo {}; int main() { auto d1 = new Derived1; auto d2 = new Derived2; } --
core.sys.posix.setjmp unavailable for OS X?
Is there a reason that it's unavailable on OS X when it works fine on Linux? The functions exist on OS X, and it's easy enough to compile C programs using setjmp there; but not D programs. I don't think I'm getting a betterC experience on the Mac. I'd also ask why the there are no D docs for core.sys.posix but I read the responses to the last time the question was asked and now I'm D-pressed. :-(
How to imporve D-translation of these Python list comprehensions ?
A workmate has recently shown this piece of code to show how nice Python is (we are mostly C and growing C++ shop): import json from itertools import chain srv1 = {'acs': {'ver': '1.2.3', 'rev': '6f2260d'}, 'cms': {'ver': '4.5', 'rev': 'b17a67e'}, 'ots': {'ver': '6.7.80', 'rev': '4f487d2'}} srv2 = {'acs': {'ver': '1.2.3', 'rev': '6f2260d'}, 'cms': {'ver': '5.1', 'rev': '2a56c53'}, 'vaa': {'ver':'0.7', 'rev': '00852cb'}} def aget(d, k1, k2): return d.get(k1, {}).get(k2, '') aa = ['ver', 'rev'] kk = set(chain(srv1.keys(), srv2.keys())) dd = [dict(_name=k, **{a + str(i): aget(d, k, a) for a in aa for i, d in enumerate([srv1, srv2])}) for k in sorted(kk)] print(json.dumps(dd, indent=2, sort_keys=True)) Output is: [ { "_name": "acs", "rev0": "6f2260d", "rev1": "6f2260d", "ver0": "1.2.3", "ver1": "1.2.3" }, { "_name": "cms", "rev0": "b17a67e", "rev1": "2a56c53", "ver0": "4.5", "ver1": "5.1" }, { "_name": "ots", "rev0": "4f487d2", "rev1": "", "ver0": "6.7.80", "ver1": "" }, { "_name": "vaa", "rev0": "", "rev1": "00852cb", "ver0": "", "ver1": "0.7" ] } Another coworker replied with Scala equivalent. So I thought, why wouldn't I join the party and translate that to D :) My best take so far is (with some D-intro comments https://run.dlang.io/is/GxsauU): import std.stdio; import std.algorithm; import std.range; import std.array; import std.conv; import std.json; void main() { // not `immutable` to describe one less thing const srv1 = [ "acs": ["ver": "1.2.3", "rev": "6f2260d"], "cms": ["ver": "4.5", "rev": "b17a67e"], "ots": ["ver": "6.7.80", "rev": "4f487d2"]]; const srv2 = [ "acs": ["ver": "1.2.3", "rev": "6f2260d"], "cms": ["ver": "5.1", "rev": "2a56c53"], "vaa": ["ver":"0.7", "rev": "00852cb"]]; string[string][] result; chain(srv1.keys, srv2.keys) .sort .uniq .each!( (uniqComp) { auto verInfo = ["_name": uniqComp]; [srv1, srv2] .enumerate .each!( serv => ["ver", "rev"].each!( prop => verInfo[prop ~ serv.index.to!string] = serv.value.get(uniqComp, ["": ""]).get(prop, "")) ); /+ // The same as above and I like this better, actually foreach(servIdx, serv; [srv1, srv2].enumerate){ foreach(prop; ["ver", "rev"]) verInfo[prop ~ servIdx.to!string] = serv.get(uniqComp, ["": ""]).get(prop, ""); } +/ result ~= verInfo; }); writeln("---"); writeln(JSONValue(result).toPrettyString()); writeln("---"); } I think, most clear code would be with tripple `foreach`, so I'll go with that. But probably someone will come up with something better and range-ier. Suggestion are welcome! --- Alexander
[Issue 17462] Order of base interfaces affects compiler behavior
https://issues.dlang.org/show_bug.cgi?id=17462 Rainer Schuetzechanged: What|Removed |Added CC||r.sagita...@gmx.de --- Comment #3 from Rainer Schuetze --- I always considered it a great relief that you don't have to reimplement common interfaces. Otherwise COM-programming would be much more verbose. What's the reasoning to disallow it? The old samples in dmd/samples also assume that IUnknown doesn't have to be reimplemented. --
Re: [theory] What is a type?
On Sunday, 10 October 2010 at 12:28:32 UTC, Justin Johansson wrote: Specifically I have a problem in trying to implement a functional language translator in D. My target language has a rather non-conventional type system, in which, superficially at least, types can be described as being Cartesian in nature. That is, types in this system have two orthogonal dimensions: (1) classical data-type (e.g. boolean, number, string, object) and (2) Kleene cardinality (occurrences) with respect to (1). The axial origin of this Cartesian type-system correlates well with the concept of the "top" type (AKA "Unit" in Scala) and as the rather adhoc "void" type in many Algol-derived languages such as C/C++/Java/D. So along axis 1 we might broadly describe the classical data types as item, boolean, number, string, object where item is effectively either a superclass or variant of the other mentioned types. Along axis 2 we describe Kleene occurrences of 1 as may be passed contractually to a receiving function. These occurrences may be enumerated six-fold as: zeroOrMore zeroOrOne oneOrMore exactlyZero exactlyOne none Readers may see that, for example, zeroOrOne is a special case (perhaps a subclass?) of zeroOrMore. exactlyOne is a special case of both zeroOrOne and oneOrMore (sounds like multiple inheritance?). OTOH, exactlyZero is a special case of zeroOrOne, which, in turn, is a special case of zeroOrmore. none is a special case of all of the above and reflects the cardinality facet of the return type of a function that never returns (say as by throwing an exception). To make this type system even more enigmatic lets add a third dimension, taking the 2-D Cartesian type system model to a 3-D Spatial model, by imagining a further degree of freedom with respect to laziness of evaluation (AKA closure of arguments). Now having hopefully described that a type is something that might well have multiple orthogonal aspects to its identity, how would one go about implementing a dynamic language with such a complex type system in D? I realize that this is a complex topic and that it might require better articulation than so far I have given. Nevertheless, thanks for all replies, Justin Johansson I'm getting "nostalgia" from all the math terminology :) Here are some of my thoughts: You've taken one property, cardinality, and put that on one axis and then declared all other properties in your system should be orthogonal to cardinality. But then you said that "string" was on the other axis, which itself is of type zeroOrMore(char), violating your own system. You also need to take into account that cardinality is multi-dimensional. i.e. you could have zeroOrMore(char) or zeroOrMore(zeroOrMore(char)). That being said, I don't think this model really get much closer to answering the original question, "what is a type?". A while back I watched a cppcon talk from Dan Saks who defined what a data type was in C++: https://www.youtube.com/watch?v=D7Sd8A6_fYU#t=58m59s Note that the whole video also contains alot of good information. It explores the social aspects being a programmer and is definitely worth watching. In his video he declares a data type as a "bundle of compile-time properties for an object", namely 1. size/alignment 2. set of values 3. set of permitted operations This model is a very good breakdown of what a type is in C++. D's a bit more complex. When you say "type" in D, there's alot more things you could be talking about so you either need to expand your definition of what a type is, or restrict the entities you consider to be types. But these 3 properties are a good start :) A bit off topic. I find it frustrating that types always need to have these 3 properties. Most of the time a programmer doesn't care about size/alignment, they just want the set of values and operations. D can allow a programmer to do this using templates, but that "throws the baby out with the bath water". You almost always require subset of properties. Because template don't define any of the properties, you end up with cryptic template error messages. D's tried to make the problem better by using conditional templates and C++ is trying to solve this with "Concepts". I've explored these ideas for a long time and am still currently developing my own methods for solving these problems. My latest idea is that you can create different "type interfaces". At a minimum, I've defined a type to be a "pure function" that takes any value and maps it to a boolean indicating whether or not that value is a member of that type. That's the "minimum interface", but you could also have a type that declares other properties, such as, a set of "values", or size/alignment. However, it's important to allow a developer to work with types that don't necessarily define all these properties for every time. Anyway, I'm mostly just sharing some of my thoughts. I have alot to say on this subject
[Issue 17462] Order of base interfaces affects compiler behavior
https://issues.dlang.org/show_bug.cgi?id=17462 Andrei Alexandrescuchanged: What|Removed |Added CC||and...@erdani.com --- Comment #2 from Andrei Alexandrescu --- FWIW the Java code works without requiring the additional implementation: interface Marker {} interface Foo { void foo(); } interface FooMarked extends Foo, Marker {} interface MarkedFoo extends Marker, Foo {} class Base implements Foo { public void foo() {} } class Derived1 extends Base implements FooMarked {} // Inherit Base.foo class Derived2 extends Base implements MarkedFoo {} // Inherit Base.foo --
Re: Proposed Phobos equivalent of wcswidth()
On Monday, January 15, 2018 10:37:14 H. S. Teoh via Digitalmars-d wrote: > On Mon, Jan 15, 2018 at 06:20:16PM +, Jack Stouffer via Digitalmars-d wrote: > > On Monday, 15 January 2018 at 17:32:40 UTC, H. S. Teoh wrote: > > > On Mon, Jan 15, 2018 at 02:14:56PM +, Simen Kjærås via > > > Digitalmars-d > > > > > > wrote: > > > > On Monday, 15 January 2018 at 13:34:09 UTC, Jack Stouffer wrote: > > > > > std.utf.displayWidth > > > > > > > > +1 > > > > > > [...] > > > > > > Why std.utf rather than std.uni, though? > > > > The way I understand it is that std.uni is (supposed to be) for > > functions on individual unicode units (be they code units/points or > > graphemes) and std.utf is for functions which handle operating on > > unicode strings. > > Are you sure? I thought std.utf was specifically dealing with UTF-* > encodings, i.e., code units and conversions to/from code points, and > std.uni was supposed to be for implementing Unicode algorithms and > Unicode compliance in general, i.e., stuff that works at the code point > level. Your understanding of the division more or less matches mine, though I'm not sure that the line is entirely clearcut. I would definitely think that std.uni was the more appropriate place for such a function. - Jonathan M Davis
[Issue 18240] New: core.stdc.wchar_ wmemset, etc. should be pure
https://issues.dlang.org/show_bug.cgi?id=18240 Issue ID: 18240 Summary: core.stdc.wchar_ wmemset, etc. should be pure Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: minor Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: n8sh.second...@hotmail.com Functions in core.stdc.wchar_ should have the same purity as the corresponding non-wide functions in core.stc.string. --
Re: Proposed Phobos equivalent of wcswidth()
On Mon, Jan 15, 2018 at 06:20:16PM +, Jack Stouffer via Digitalmars-d wrote: > On Monday, 15 January 2018 at 17:32:40 UTC, H. S. Teoh wrote: > > On Mon, Jan 15, 2018 at 02:14:56PM +, Simen Kjærås via Digitalmars-d > > wrote: > > > On Monday, 15 January 2018 at 13:34:09 UTC, Jack Stouffer wrote: > > > > std.utf.displayWidth > > > > > > +1 > > [...] > > > > Why std.utf rather than std.uni, though? > > The way I understand it is that std.uni is (supposed to be) for > functions on individual unicode units (be they code units/points or > graphemes) and std.utf is for functions which handle operating on > unicode strings. Are you sure? I thought std.utf was specifically dealing with UTF-* encodings, i.e., code units and conversions to/from code points, and std.uni was supposed to be for implementing Unicode algorithms and Unicode compliance in general, i.e., stuff that works at the code point level. > Obviously there are exceptions. I think "they" put graphemeStride in > std.uni because Grapheme was defined there and it seemed reasonable at > the time. But, generally I think utf stuff should go into std.utf. But displayWidth isn't really directly related to UTF (i.e., the encoding of Unicode code points). It seems to me to be more to do with processing Unicode in general, though, granted, the optimizations I implemented are kinda in a grey zone between dealing with Unicode proper (i.e., with code points) vs. working with code units. T -- Klein bottle for rent ... inquire within. -- Stephen Mulraney
[Issue 18239] std.experimental.allocator fillWithMemcpy could use memset when T.sizeof==1
https://issues.dlang.org/show_bug.cgi?id=18239 --- Comment #2 from Nathan S.--- (In reply to Nathan S. from comment #1) > Could also use wmemset when T.sizeof == wint_t.sizeof Unfortunately core.stdc.wchar_.wmemset isn't marked as pure so this would cause some tests to fail. --
[Issue 18239] std.experimental.allocator fillWithMemcpy could use memset when T.sizeof==1
https://issues.dlang.org/show_bug.cgi?id=18239 Nathan S.changed: What|Removed |Added Summary|std.experimental.allocator |std.experimental.allocator |fillWithMemcpy could use|fillWithMemcpy could use |memset/wmemset for |memset when T.sizeof==1 |T.sizeof==1 or | |wint_t.sizeof | --
[Issue 18239] std.experimental.allocator fillWithMemcpy could use memset/wmemset for T.sizeof==1 or wint_t.sizeof
https://issues.dlang.org/show_bug.cgi?id=18239 --- Comment #1 from Nathan S.--- Could also use wmemset when T.sizeof == wint_t.sizeof --
[Issue 18239] std.experimental.allocator fillWithMemcpy could use memset/wmemset for T.sizeof==1 or wint_t.sizeof
https://issues.dlang.org/show_bug.cgi?id=18239 Nathan S.changed: What|Removed |Added Summary|std.experimental.allocator |std.experimental.allocator |fillWithMemcpy could use|fillWithMemcpy could use |memset when T.sizeof==1 |memset/wmemset for ||T.sizeof==1 or ||wint_t.sizeof --
mysql-native: Prepared statements: Direction and future
I've posted (what basically amounts to an article) about my current thoughts on addressing Prepared's current downsides in the next release (v2.0.0), as well as a little bit of future direction of the lib. Anyone interested in mysql-native's prepared statements (especially their interplay with connection pools) is encouraged to take a look and share any thoughts: https://github.com/mysql-d/mysql-native/issues/95#issuecomment-357757013
Re: Proposed Phobos equivalent of wcswidth()
On Monday, 15 January 2018 at 17:32:40 UTC, H. S. Teoh wrote: On Mon, Jan 15, 2018 at 02:14:56PM +, Simen Kjærås via Digitalmars-d wrote: On Monday, 15 January 2018 at 13:34:09 UTC, Jack Stouffer wrote: > std.utf.displayWidth +1 [...] Why std.utf rather than std.uni, though? The way I understand it is that std.uni is (supposed to be) for functions on individual unicode units (be they code units/points or graphemes) and std.utf is for functions which handle operating on unicode strings. Obviously there are exceptions. I think "they" put graphemeStride in std.uni because Grapheme was defined there and it seemed reasonable at the time. But, generally I think utf stuff should go into std.utf.
[Issue 18239] New: std.experimental.allocator fillWithMemcpy could use memset when T.sizeof==1
https://issues.dlang.org/show_bug.cgi?id=18239 Issue ID: 18239 Summary: std.experimental.allocator fillWithMemcpy could use memset when T.sizeof==1 Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: n8sh.second...@hotmail.com Current function in std.experimental.allocator.package: ``` private void fillWithMemcpy(T)(void[] array, auto ref T filler) nothrow { import core.stdc.string : memcpy; import std.algorithm.comparison : min; if (!array.length) return; memcpy(array.ptr, , T.sizeof); // Fill the array from the initialized portion of itself exponentially. for (size_t offset = T.sizeof; offset < array.length; ) { size_t extent = min(offset, array.length - offset); memcpy(array.ptr + offset, array.ptr, extent); offset += extent; } } ``` When T.sizeof==1 we could use memset instead. If this change is made it might be a good idea to change the name of the function to avoid an implicit contract that it uses the memcpy function. --
Does it have an http2 server/client lib like in golang?
subj
Re: How to run vibe.d web app in XAMPP server ?
On Monday, 15 January 2018 at 06:22:13 UTC, Jayam wrote: Is there any way how to deploy the vibe.d web app into XAMPP ? No you cant deploy vibe.d web app into XAMPP. What you can do is to install vibe.d to the same server and tell apache to proxy all requests to vibe.d. I dont know enough about servers to tell you exactly how to do it but it should be the same as setting up node.js. https://stackoverflow.com/questions/9831594/apache-and-node-js-on-the-same-server I hope this helps
Re: Proposed Phobos equivalent of wcswidth()
On Mon, Jan 15, 2018 at 02:14:56PM +, Simen Kjærås via Digitalmars-d wrote: > On Monday, 15 January 2018 at 13:34:09 UTC, Jack Stouffer wrote: > > std.utf.displayWidth > > +1 [...] Why std.utf rather than std.uni, though? T -- ASCII stupid question, getty stupid ANSI.
Re: Article: Fuzzing D code with LDC
On Monday, 15 January 2018 at 09:49:24 UTC, Temtaime wrote: // `Throwable`s thrown are not bugs (in contrast to `Errors`). They _can_ be bugs. class Error : Throwable class Exception : Throwable Good catch ( ;-) ) thanks. -Johan
Re: Cannot use local lambda as parameter to non-global template
On Monday, 15 January 2018 at 15:27:23 UTC, Meta wrote: void main() { auto arr = [1, 2, 3]; arr.remove!(_ => _ == 1); writeln(arr); } Or was that code meant as an example? The problem occurs when the templated function is a member of the struct `arr`. I've moved the algorithm into a free function here https://github.com/nordlow/phobos-next/blob/master/src/hashmap_or_hashset.d#L1190 instead. I've changed the name to `removeAllMatching` for now.
Re: Cannot use local lambda as parameter to non-global template
On 01/15/2018 07:27 AM, Meta wrote: On Monday, 15 January 2018 at 13:55:57 UTC, Nordlöw wrote: The function `remove` is a templated member of a struct instance `x`. Can you give a bit more context? The following code does not cause a compile error: import std.stdio; import std.algorithm; void main() { auto arr = [1, 2, 3]; arr.remove!(_ => _ == 1); writeln(arr); } Or was that code meant as an example? import std.algorithm; struct S { int[] elements; void remove(alias func)() { // ... } void remove(string s)() { foreach (a; elements) { const cond = mixin(s); if (cond) { // do remove } } } } void main() { auto s = S(); s.remove!"a == 11"(); // Fails compilation: // s.remove!(_ => _ == 1); } Ali
Re: run.dlang.io can now display ASM + AST + IR
On Sunday, 14 January 2018 at 04:18:41 UTC, Seb wrote: It was bad weather in Munich on Saturday, so run.dlang.io got a couple of new cool features: 1) Assembly output ... 2) AST of DMD frontend (after semantic analysis) ... 3) IR (LDC only) ... 4) Permanent flags 5) Stores the latest source file in the persistent localStorage of your browser 6) Small UI updates Yes! Very cool!
Re: Proposed Phobos equivalent of wcswidth()
On Monday, 15 January 2018 at 15:08:24 UTC, Kagamin wrote: columnWidth as it only makes sense for column-oriented text display. I think displayWidth is better, because "width" is directly linked to hozizontal direction (else it would be called hight), and setting text in colums would still take additional steps to be set correct. Also "display" indicates that it has nothing to do with the string length, which is good to avoid confusion.
Web Application Development
We create web applications from the ground up, tailored to your specific needs and that of your business. Weather you need to digitise an existing paper-based form or you want to build a ground-breaking social network. We've got it covered. We use the latest languages, frameworks and development techniques available to ensure your application is future proofed with the most reliable and secure of technology. https://viewport-tech.com/web-application-development
Re: String Type Usage. String vs DString vs WString
On Monday, 15 January 2018 at 14:44:46 UTC, Adam D. Ruppe wrote: On Monday, 15 January 2018 at 06:18:27 UTC, SimonN wrote: D's foreach [...] will autodecode and silently iterate over dchar, not char, even when the input is string That's not true. foreach will only decode on demand: foreach(c; s) { /* c is a char here, it goes over bytes */ } Thanks for the correction! Surprised I got foreach(c, s) wrong, its non-decoding iteration is even the prominent example in TDPL. Even `each`, the template function that implements a foreach, still infers as char: "aä".each!writeln; // prints a plus two broken characters Only `map` When I wrote "D's ranges", I meant Phobos's range-producing templates; a range itself is again encoding-agnostic.
Re: String Type Usage. String vs DString vs WString
On Monday, January 15, 2018 14:56:33 Kagamin via Digitalmars-d-learn wrote: > On Monday, 15 January 2018 at 06:18:27 UTC, SimonN wrote: > > D's foreach and D's ranges will autodecode and silently iterate > > over dchar, not char > > foreach doesn't do it silently, decoding must be requested from > it by explicitly specifying element type, it can also encode this > way. Yeah, one of the joys of that is that you have to be careful of using foreach in range-based functions, because if you haven't specialized for strings, and you use foreach without specifying the element type, then when your function template is instantiated with a string, the foreach won't match what front does. I really don't have any complaints about how foreach does this aside from the fact that it doesn't currently use the replacement character (so, it will throw on invalid Unicode if it's told to decode), but the way that interacts with Phobos is poor. Ideally, we'd get rid of auto-decoding, and we'd get rid of the whole exception on bad Unicode thing and just use the replacement character, but since changing it would break a lot of code... :| - Jonathan M Davis
Re: What's equivalent to C#'s select?
On Monday, 15 January 2018 at 15:24:50 UTC, Marc wrote: I just thought that filter() could be evaluated at compile time too, as others function that I've used so far. Sometimes I don't know if a native function can be evaluated at compile time until I do enum x = func(); Yeah, it takes some getting used to what happens when and how these interact. I can recommend H. S. Teoh's writeup: https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time if I want to have minimum runtime code to filter out immutable strings, the first one is better right? Indeed. It generates the equivalent code to just writing the writeln()s you want, with no run-time overhead. -- Simen
Re: I want to transmit the class name and the member name in the method
On Friday, 5 January 2018 at 07:40:14 UTC, Brian wrote: auto db = new ORM; auto users = db.select(User).where(email.like("*@hotmail.com")).limit(10); Expression templates are a dead-end for any non-trivial queries. You have to embrace SQL to properly use RDMS, at the cost of beginners having to learn it. There is no free lunch and the inefficient queries ppl. are running with Rails examplify what happens, when you pretend it's possible to use technology without understanding it. I'm actively working towards a design that allows full compile-time typing with plain SQL commands. This will still take a while, but I hope we can see an alpha in 2018H1. http://dconf.org/2016/talks/nowak.html alias schema = AliasSeq!(User, MailAddress, Book, Lending); DB!schema db = DB!schema(SQLite("local.db")); // connecting checks for missing/additional migrations db = DB!schema(MySQL("localhost", 3306)); // DB wrapper is driver agnostic // Full ANSI SQL // driver-specific functions when picking the driver at compile time // You can always exec dynamic queries on the underlying driver foreach (r; db.exec!(q"SQL SELECT u.name, m.addr, CONCAT(b.title, ';') books FROM users u JOIN mail_addresses m ON m.user_id = u.id AND NOT u.can_overdraw JOIN lendings l ON l.user_id = u.id AND DATEDIFF(NOW(), l.end_date) >= 7 JOIN books b ON b.lending_id = l.id WHERE b.amount < 20 GROUP BY u.id SQL ) sendMail(r.name, r.addr, r.books.splitter(';')); More concise stuff is possible with heavy compile-time trickery (https://dpaste.dzfl.pl/cd375ac594cf) without incurring dreaded 1+N queries or even any unnecessary SELECT fields. foreach (u; db.select!User.where!"NOT can_overdraw") { sendMail(u.name, u.mail.addr, u.lendings // no 1+N here .where!"DATEDIFF(NOW(), end_date) >= 7 AND book.amount < 20") .map!(l => l.book.Reminder)); // client side range API } This has become even more of a challenge since we plan to make it a @safe @nogc poster child. If anyone wants to help with this project please contact me. At the moment reworked @safe @nogc database drivers would be most helpful. I'll soon publish a small RC, Uniq, Weak library. Unbuffered IO foundations are already here https://github.com/MartinNowak/io, but not yet practically proven, and still lacking vibe-core scheduler/eventcore integration.
Re: Cannot use local lambda as parameter to non-global template
On Monday, 15 January 2018 at 13:55:57 UTC, Nordlöw wrote: Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for x.remove!(_ => _ == 1); but not for x.remove!"a == 11"; ? How are these two lambdas different? The function `remove` is a templated member of a struct instance `x`. Can you give a bit more context? The following code does not cause a compile error: import std.stdio; import std.algorithm; void main() { auto arr = [1, 2, 3]; arr.remove!(_ => _ == 1); writeln(arr); } Or was that code meant as an example?
Re: What's equivalent to C#'s select?
On Monday, 15 January 2018 at 07:37:42 UTC, Simen Kjærås wrote: On Sunday, 14 January 2018 at 22:07:22 UTC, Marc wrote: thanks, can i use it at compile time as well? enum isMutableString(string field) = is(typeof(__traits(getMember, >C, field)) == string); static foreach(field; [FieldNameTuple!C].filter!(f => isMutableString!(f))) { writeln(field); } You're mixing compile-time and run-time logic here in a way that D doesn't allow. In particular, isMutableString requires the passed string to be a compile-time constant, and filter works on run-time values. I just thought that filter() could be evaluated at compile time too, as others function that I've used so far. Sometimes I don't know if a native function can be evaluated at compile time until I do enum x = func(); There are a few different ways to resolve this. First, std.meta has the Filter template, which behaves much in the same way as std.algorithm.filter, but with compile-time tuples: static foreach (field; Filter!(isMutableString, FieldNameTuple!C)) { writeln(field); } The other option is to rewrite isMutableString to work with run-time values: bool isMutableString(string field) { switch (field) { foreach (cField; FieldNameTuple!C) { case cField: return is(typeof(__traits(getMember, C, cField)) == string); } default: return false; } } static foreach(field; [FieldNameTuple!C].filter!(f => isMutableString(f))) { writeln(field); } Both of these give the same output, and should be what you want. -- Simen That's exactly it! That Filter() from std.algorithm works like I wanted :) nice solution also with rewrite the function to work with run-time so that i can use with filter() but if I want to have minimum runtime code to filter out immutable strings, the first one is better right?
Re: Cannot use local lambda as parameter to non-global template
On 2018-01-15 14:55, Nordlöw wrote: Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for x.remove!(_ => _ == 1); but not for x.remove!"a == 11"; ? How are these two lambdas different? The function `remove` is a templated member of a struct instance `x`. The difference is that the string version would not capture the surrounding context while the lambda version does. It's something related to that the lambda needs to capture both the this object, since "remove" is member of a struct, and capturing the local context of where "remove" is called. A lambda/delegate can only have one context pointer. There's an issue already reported for this. -- /Jacob Carlborg
Re: Proposed Phobos equivalent of wcswidth()
columnWidth as it only makes sense for column-oriented text display.
Re: Using Postgres connection functions
On Monday, 15 January 2018 at 02:28:29 UTC, Matthias Klumpp wrote: In any case, please don't start another Postgres library and consider contributing to one of the existing ones, so that we maybe have one really awesome, 100% complete library at some point. If, on the other hand, your goal is to learn about the low-level Postgres interface and not just to have a Postgres interface for an application you develop, by all means, play with it :-) At this point, I am indeed learning about low-level Postgres interfaces (but not so low-level as the client-server protocol) as a way to understand the challenges of interfacing D to C. However, as part of the Pyrseas open source project, which I maintain, I had started to create a Postgres interface in Python inspired by The Third Manifesto, as opposed to ORMs like SQLAlchemy (see https://pyrseas.wordpress.com/2013/03/07/a-pythonic-ttm-inspired-interface-to-postgresql-requirements/). I got criticized for "reinventing the wheel" but I believe TTM, if properly done, is quite different from an ORM. I understand your concern about not starting another PG library. From the cursory investigation of the existing libraries, I think they span a spectrum, with ddb at one end (low-level protocol), then derelict-pq (low-level binding over libpq), ddbc at the opposite end (multi-DBMS support) and several others in between. So I guess the real problem is with the proliferation in the latter group.
Re: Cannot use local lambda as parameter to non-global template
On Monday, 15 January 2018 at 13:55:57 UTC, Nordlöw wrote: Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for x.remove!(_ => _ == 1); but not for x.remove!"a == 11"; ? How are these two lambdas different? The function `remove` is a templated member of a struct instance `x`. It's a bit involved, but boils down to this: lambdas in D can only have one context pointer. A simple example: class Foo { int n = 2; int run(alias fun)(int m) { return fun(n, m); } } unittest { int a = 3; int fn(int n, int m) { return a + n + m; } assert((new Foo).run!fn(4) == 9); } fn obviously requires a pointer to the context in the unittest block, since it uses 'a' in that context. Somewhat less obviously, it also needs a pointer to the Foo instance in which it is run. Since 2 > 1, this fails. There's a bug reported for it: https://issues.dlang.org/show_bug.cgi?id=5710, and even a $200 bounty for fixing it: https://www.bountysource.com/issues/1375082 The bug report is almost seven years old, so it seems this is a hard bug to squash. Luckily, there are some workarounds. One you've already found. Others include moving templates to scopes where less context is needed (e.g. moving a function template that is associated with a class, but doesn't need to be part of it, outside the class), and marking your lambdas 'static'. A static lambda does not have a context pointer to the scope in which it is declared, and so cannot use variables declared in it. For instance, fn above uses 'a' in the same scope, and so cannot be marked static. -- Simen
Re: String Type Usage. String vs DString vs WString
On Monday, 15 January 2018 at 06:18:27 UTC, SimonN wrote: D's foreach and D's ranges will autodecode and silently iterate over dchar, not char foreach doesn't do it silently, decoding must be requested from it by explicitly specifying element type, it can also encode this way.
Re: String Type Usage. String vs DString vs WString
On Monday, 15 January 2018 at 06:18:27 UTC, SimonN wrote: D's foreach [...] will autodecode and silently iterate over dchar, not char, even when the input is string That's not true. foreach will only decode on demand: string s; foreach(c; s) { /* c is a char here, it goes over bytes */ } foreach(char c; s) { /* c is a char here, same as above */ } foreach(dchar c; s) { /* c is a dchar - this decodes */ } Autodecoding is a Phobos library artifact, NOT something in the D language itself.
Re: Proposed Phobos equivalent of wcswidth()
On Monday, 15 January 2018 at 13:34:09 UTC, Jack Stouffer wrote: std.utf.displayWidth +1 -- Simen
[Issue 18230] multiwayUnion sets wrong pred lambdas
https://issues.dlang.org/show_bug.cgi?id=18230 RazvanNchanged: What|Removed |Added CC||razvan.nitu1...@gmail.com --- Comment #1 from RazvanN --- PR : https://github.com/dlang/phobos/pull/6032 --
Cannot use local lambda as parameter to non-global template
Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for x.remove!(_ => _ == 1); but not for x.remove!"a == 11"; ? How are these two lambdas different? The function `remove` is a templated member of a struct instance `x`.
Re: Bump the minimal version required to compile DMD to 2.076.1
Btw, ther is a gdc which stil uses c++ version of dfrontend, so on DragonFlyBSD you can build dmd using gdc. On Mon, Jan 15, 2018 at 2:25 PM, Daniel Kozakwrote: > So why not to use cross compilation? > > On Mon, Jan 15, 2018 at 2:10 PM, Joakim via Digitalmars-d < > digitalmars-d@puremagic.com> wrote: > >> On Monday, 15 January 2018 at 12:15:27 UTC, Temtaime wrote: >> >>> And what builds C++ compiler from source ? :) >>> >> >> The system C/C++ compiler is already built and there, obviously. Since >> nobody ships a D compiler with their OS, I'm not sure how you think that's >> relevant. >> >> On Monday, 15 January 2018 at 12:36:04 UTC, Daniel Kozak wrote: >> >>> Exactly, there is no reason to build 2.067, 2.076, and 2.078, just build >>> the latest one with the previos one. It is common (in case you do not have >>> dlang compiler in your distribution) to start with downloading existing >>> binary and compile lastest version as a package, then you can use this >>> package as a dependency for building new versions. >>> >> >> There is no existing binary for an OS that doesn't have a port yet! >> >> Take the current DragonFlyBSD port that's being done: he had to port both >> dmd 2.067, which is written in C++, and the latest dmd master to DragonFly, >> in order to have source packages for their ports repository: >> >> https://github.com/dlang/dmd/pull/7463 >> >> If you bump the D compiler required for latest master, he'll have to port >> every bumped D compiler too, ie 2.067, 2.076, and 2.078, in order to have a >> source package. That's going to be a huge pain that will stop many from >> doing the initial port. >> > >
Re: String Type Usage. String vs DString vs WString
On Monday, 15 January 2018 at 04:27:15 UTC, Jonathan M Davis wrote: On Monday, January 15, 2018 03:14:02 Tony via Digitalmars-d-learn wrote: On Monday, 15 January 2018 at 02:09:25 UTC, rikki cattermole wrote: > Unicode has three main variants, UTF-8, UTF-16 and UTF-32. > The size of a code point is 1, 2 or 4 bytes. I think to be technically correct, 1 (UTF-8), 2 (UTF-16) or 4 (UTF-32) bytes are referred to as "code units" and the size of a code point varies in UTF-8 and UTF-16. Yes, for UTF-8, a code unit is 8 bits, and there can be up to 6 of them (IIRC) in a code point. Nooo!!! Only 4 maximum for Unicode. Beyond that it's obsolete crap that is not Unicode since version 2 of Unicode.
Re: Proposed Phobos equivalent of wcswidth()
On Saturday, 13 January 2018 at 17:26:52 UTC, H. S. Teoh wrote: ... Thanks for taking the time to do this. And now the obligatory bikeshed: what should the Phobos equivalent of wcswidth be called? std.utf.displayWidth
Re: Bump the minimal version required to compile DMD to 2.076.1
So why not to use cross compilation? On Mon, Jan 15, 2018 at 2:10 PM, Joakim via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On Monday, 15 January 2018 at 12:15:27 UTC, Temtaime wrote: > >> And what builds C++ compiler from source ? :) >> > > The system C/C++ compiler is already built and there, obviously. Since > nobody ships a D compiler with their OS, I'm not sure how you think that's > relevant. > > On Monday, 15 January 2018 at 12:36:04 UTC, Daniel Kozak wrote: > >> Exactly, there is no reason to build 2.067, 2.076, and 2.078, just build >> the latest one with the previos one. It is common (in case you do not have >> dlang compiler in your distribution) to start with downloading existing >> binary and compile lastest version as a package, then you can use this >> package as a dependency for building new versions. >> > > There is no existing binary for an OS that doesn't have a port yet! > > Take the current DragonFlyBSD port that's being done: he had to port both > dmd 2.067, which is written in C++, and the latest dmd master to DragonFly, > in order to have source packages for their ports repository: > > https://github.com/dlang/dmd/pull/7463 > > If you bump the D compiler required for latest master, he'll have to port > every bumped D compiler too, ie 2.067, 2.076, and 2.078, in order to have a > source package. That's going to be a huge pain that will stop many from > doing the initial port. >
Re: Bump the minimal version required to compile DMD to 2.076.1
On Monday, 15 January 2018 at 12:15:27 UTC, Temtaime wrote: And what builds C++ compiler from source ? :) The system C/C++ compiler is already built and there, obviously. Since nobody ships a D compiler with their OS, I'm not sure how you think that's relevant. On Monday, 15 January 2018 at 12:36:04 UTC, Daniel Kozak wrote: Exactly, there is no reason to build 2.067, 2.076, and 2.078, just build the latest one with the previos one. It is common (in case you do not have dlang compiler in your distribution) to start with downloading existing binary and compile lastest version as a package, then you can use this package as a dependency for building new versions. There is no existing binary for an OS that doesn't have a port yet! Take the current DragonFlyBSD port that's being done: he had to port both dmd 2.067, which is written in C++, and the latest dmd master to DragonFly, in order to have source packages for their ports repository: https://github.com/dlang/dmd/pull/7463 If you bump the D compiler required for latest master, he'll have to port every bumped D compiler too, ie 2.067, 2.076, and 2.078, in order to have a source package. That's going to be a huge pain that will stop many from doing the initial port.
Re: Bump the minimal version required to compile DMD to 2.076.1
Exactly, there is no reason to build 2.067, 2.076, and 2.078, just build the latest one with the previos one. It is common (in case you do not have dlang compiler in your distribution) to start with downloading existing binary and compile lastest version as a package, then you can use this package as a dependency for building new versions. On Mon, Jan 15, 2018 at 1:15 PM, Temtaime via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > And what builds C++ compiler from source ? :) >
Re: Bump the minimal version required to compile DMD to 2.076.1
And what builds C++ compiler from source ? :)
I didn't succeed in creating an empty project for a long time
zoujiaqing@Brian-XPS MINGW64 /d/Projects $ dub init serializable -v Using dub registry url 'https://code.dlang.org/' Refreshing local packages (refresh existing: true)... Looking for local package map at C:\ProgramData\dub\packages\local-packages.json Looking for local package map at C:\Users\Brian\AppData\Roaming\dub\packages\local-packages.json No package found in current working directory.