Re: matrix library
On Monday, 23 May 2016 at 23:08:46 UTC, Vlad Levenfeld wrote: Now I am thinking that the best way to orthogonalize (sorry) my efforts with respect to mir and scid.linalg is to use them as backend drivers, maintain this wrapper for the crowd that isn't as familiar with blas/lapack, or wants to write slightly more concise top-level code, and forward the relevant bug reports and pull requests to mir and scid. You might be interested in joining the gitter channel where the mir developers hang out: https://gitter.im/libmir/public
Re: DDT 1.0.0 released.
On Tuesday, 17 May 2016 at 14:04:04 UTC, Bruno Medeiros wrote: New DDT release out: dfmt support, performance improvements to semantic operations, more build command customization, fixes. Please see changelog for full list: https://github.com/DDT-IDE/DDT/releases/tag/v1.0.0 Since DDT has generally been quite stable, and since the current release is very close to the end-game vision I had for a D IDE - at least as far as my free time would allow to create - I've decided to version this as 1.0. I've been working for nearly 8 years on this project after all (with some intermission periods), so I guess 1.0 was a bit due... O.o' I expect it will mainly be small updates from now on, not any major new features (other than perhaps DCD support). For Eclipse/DDT under Windows now you can use Mago-MI debugger for debugging of DMD/x86 generated programs. Precompiled binaries are available in DlangIDE release bundle. https://github.com/buggins/dlangide/releases/tag/v0.6.5 Added support for a lot of GDB/MI commands. Compatibility with GDB fixed. Tested with Eclipse/DDT. You can build dmd/x86 project in Eclipse/DDT, start debugging, use breakpoints, step in/out/over, see threads, stack frames, variables. Just change Debug Configuration / Debugger setting - from GDB to mago-mi Mago-MI thread on Announce: http://forum.dlang.org/thread/wctrsimrsfpbdkgce...@forum.dlang.org On Debuggers: http://forum.dlang.org/thread/pjqmjezcgplwvpfue...@forum.dlang.org Best regards, Vadim
Re: mago-mi: GDB/MI compatible frontend for Mago debugger
On Wednesday, 18 May 2016 at 18:02:12 UTC, Bruno Medeiros wrote: While DDT technically work oks with GDB (the GDB from mingw-w64 that is), you are right, there isn't a compiler on Windows that supplies debug info in the way GDB understands. See https://wiki.dlang.org/Debuggers. DMD produces debug info COFF or OMF format, which GDB doesn't know anything about (nor ever will). LDC should in theory work with DWARF info, but this is broken somehow. Not because of LLVM though, since for example Rust on Windows works. As for GDC, it doesn't even supply binaries for Windows (that target Windows) - it is not a supported platform. BTW, Eclipse/DDT should in theory work with mago-mi as well, at least if the protocol is implemented correctly. Have you tried it? I dunno how complete your MI implementation is. mago-mi v0.2.1 is released. Precompiled binaries are available in DlangIDE release bundle. https://github.com/buggins/dlangide/releases/tag/v0.6.5 Added support for a lot of GDB/MI commands. Compatibility with GDB fixed. Tested with Eclipse/DDT. You can build dmd/x86 project in Eclipse/DDT, start debugging, use breakpoints, step in/out/over, see threads, stack frames, variables. Just change Debug Configuration / Debugger setting - from GDB to mago-mi Best regards, Vadim
Re: std.conv.parse not accepting ByCodeUnitImpl
On 05/24/2016 03:59 AM, Jack Stouffer wrote: parse!int(splitValue.front); [...] std.conv.parse(Target, Source)(ref Source s) if ( isSomeChar!(ElementType!Source) && isIntegral!Target && !is(Target == enum)) You're missing that `parse`'s parameter is `ref`. `splitValue.front` is not an lvalue, so it can't be passed in a ref parameter. This works: auto f = splitValue.front; parse!int(f);
Re: A language comparison (seeking productivity-enhancing, well-designed, and concise languages)
On Monday, 23 May 2016 at 05:37:10 UTC, Ali Çehreli wrote: Found on Reddit: https://www.reddit.com/r/programming/comments/4kmfp6/the_best_quality_programming_languages/ The list: http://www.slant.co/topics/5984/~productivity-enhancing-well-designed-and-concise-rather-than-popular-or-time-tested-programming-languag Ali That's a pretty interesting list. It's nice to see D on the top of the list
[Issue 15568] Wrong contracts generated when compiled with -O
https://issues.dlang.org/show_bug.cgi?id=15568 --- Comment #4 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/585ab7d14146ec6bc45b41e2b0b344e06dbbe1ee test Issue 15568 - Wrong contracts generated when compiled with -O https://github.com/dlang/dmd/commit/05a0edff93b611e2d67d5c77237092dd220afe75 Merge pull request #5803 from WalterBright/test15568 test Issue 15568 - Wrong contracts generated when compiled with -O --
Re: foo => "bar" key/value literals in D!
On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! --- void main() { import std.stdio; writeln(obj!( foo => "bar", baz => 12 )); } --- [...] This is a pretty amazing find! It's like a better version of "dynamic" from C#.
Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?
On Monday, 23 May 2016 at 07:03:08 UTC, chmike wrote: On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote: (This effect could be simulated by making my_var into a function, but i don't want to do that.) May I ask why you don't want to do that ? In D you can call a function without args without (). So if you write private int my_var_ = 4; // where 4 is the default initialization value @property int my_var1() { return my_var_; } final int my_var2() { return my_var_; } int my_var3() { return my_var_; } int x = obj.my_var1; x = obj.my_var2; x = obj.my_var3; my_var3 is virtual so I guess you get the overhead of a virtual method call which is probably not what you want. my_var2 can't be overriden and if it doesn't itself override a method with a same name in a base class the compiler may optimize its call by inlining it. It's like a static method with 'this' passed as argument. I'm not fully sure about my_var1. I'm still a beginner, but I think the compiler will optimize it into inlined instruction if it can as for my_var2. Making the user accessing the member variables directly may look like it's more efficient, but it's bad API design because you can't change the class implementation affecting my_var_ without breaking the API. The D way enforces good programming and API design and optimizes as much as possible. Thanks Ch Mike for your reply and explanation, and the further information about calling functions. Thanks also to the other Mike, to Daniel for the interesting union technique, and to Meta for further elaboration. Daniel's union technique is pretty close to what i was asking for. Now, since you explicitly ask me 'why you don't want to do that', i should answer. But my answer won't be nearly as good as your analysis and explanation, nor as good as any of the other replies. :( Just aesthetically, i'd like to refer to the variable within the class and outside the class with exactly the same symbol. But with all the ideas presented in the prior discussion, i can get pretty close so it would be a ridiculous point for me to complain about. Thanks again for your help! dan
Re: Diamond - MVC / Template engine
On Monday, 23 May 2016 at 16:15:08 UTC, Luís Marques wrote: On Saturday, 21 May 2016 at 08:20:00 UTC, Bauss wrote: For more information please view below. Dub repository: https://code.dlang.org/packages/diamond Github: https://github.com/bausshf/Diamond The dub repository seems to have a problem properly escaping your example template. Could you check on that, and if the problem is on the dub registry create a bug report there? Yes, I didn't even notice that :)
Re: Idea: swap with multiple arguments
On Monday, 23 May 2016 at 21:38:54 UTC, Jonathan M Davis wrote: One thing that screams out to me: this should be called rotate, not swap. That would probably be better. My immediate thought on reading Andrei's suggestion for swap was that it would be way too easy to forget what's actually being swapped when there are more than two arguments. Rotate at least implies an ordering to it. Though I confess that I've never heard of a swap function (or anything like a swap function) that's swapped more than two arguments, and I'm not aware of any point in time when I thought that such a thing might be useful. So, I'm not exactly clamoring for a function like this, but that obviously doesn't mean that it's not worth adding, just that I don't personally see any particular value in it. If you don't see value in it, you've neglected to learn PostScript. There, a similar capability is used to "rotate" a certain number of the top elements on the operand stack. However, because PostScript is a graphical language, the "rotate" operator instead does a 2D coordinate-system rotation. For the functionality that Andrei wants, PostScript uses the "roll" operator, which performs a circular shift of the top operands on the stack. Aside from those operands themselves, it takes an argument n (the number of operands to roll) and an argument j (the number of positions to roll, which can be either positive ("upward" motion on the stack) or negative ("downward" motion on the stack)). To be more visual about it, if j is 1, the top element of the stack is popped and inserted further into the stack. https://www.adobe.com/products/postscript/pdfs/PLRM.pdf (page 483 by printed-page numbering, page 489 within the PDF file) has all the details for this operator. The point is that alternative terms like "roll" and "circular shift" might be useful in naming this function, instead of either swap (which I agree is confusing) or rotate. And while n can be imputed from the number of arguments passed, it might be useful to pass j explicitly, allowing shifts of more than one position and in either direction. (Speaking of graphical contexts, if you were working in 3D, you might consider the meaning of "roll" to be "reserved", in the sense of roll/pitch/yaw.) As for utility, if you're a PostScript programmer, where keeping track of data is done via a stack-oriented model, this capability gets used all the time, to bring relevant arguments to the top of the stack to be operated upon, or to shove arguments deeper into the stack for later use.
[Issue 15568] Wrong contracts generated when compiled with -O
https://issues.dlang.org/show_bug.cgi?id=15568 Walter Brightchanged: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |WORKSFORME --- Comment #3 from Walter Bright --- This passes on all platforms in the autotester. Marking it as worksforme for now. --
std.conv.parse not accepting ByCodeUnitImpl
Consider the following code - import std.range; import std.conv; import std.utf; import std.algorithm; auto test(R)(R s) { auto value = s.byCodeUnit; auto splitValue = value.splitter('.'); parse!int(splitValue.front); } void main() { test("1.8"); } - This fails to compile and I can't for the life of me understand why. The std.conv.parse call doesn't match any parse overload when it should match the second one: - std.conv.parse(Target, Source)(ref Source s) if ( isSomeChar!(ElementType!Source) && isIntegral!Target && !is(Target == enum)) - Manually verifying the template constraints proves that it should work, - pragma(msg, isSomeChar!(ElementType!(typeof(splitValue.front))), isIntegral!int, !is(int == enum)); truetruetrue - Any help here would be appreciated.
inner functions instead of scope
Someone was mentioning how in RAII you can't tell if there's an exception condition on destruction, but to the crazy degree that D inlines functions, I think something similarly concise is possible that solves the problem. The problem I'm talking about is when you want to clean up a resource, you have to reserve it at the beginning, then free it at the end, but freeing it might be different depending on if you're failing or not. Classic case being a database transaction. begin(); try { do_stuff(); } catch(e) { rollback(); throw e; } commit(); That's the way most people would think to do it, which has the problem that if "do_stuff" is a really huge block of code, then it's hard to remember to properly rollback and commit on the bottom. There is of course the "D" way to do it. { begin(); scope(failure) rollback(); scope(success) commit(); do_stuff(); } That's what I usually go with, because it's not too verbose, is very clear on what's going on, and related code is grouped together. Some people would like to do something like this: { Transaction somevariable; do_stuff(); } But of course, when somevariable is destroyed, you can't tell whether it's because of failure or success. But it's a really concise syntax, and isn't split up into three parts like the "scope" version or the try/except mess. So, what if we could do a transaction that did have as simple a syntax? And it hit me that a big block of code could be put in an inline function, and those are pretty much exactly what would be called for. void transaction(Callable)(Callable do_stuff) if(isCallable(Callable)) { begin(); scope(failure) rollback(); scope(success) commit(); do_stuff(); } ... transaction({ big_long_complicated_code_block(); }); Once you define the "transaction" function that way, it properly commits or rolls back no matter what is in the function passed as a callable. You could even have some argument only available from within the callable, like: transaction((session) { ... }); then you could call session.commit() if you succeeded. But that's getting pretty close to "Promise" syntax, and I think the absolute most secure way to do it is not expose that things are being committed or rolled back at all, to ensure that they are always committed or rolled back. It shouldn't be any less efficient than RAII would be, since the function passed as an argument will surely be inlined automatically. So, here's how I would implement transaction management for a database. import d2sqlite3: Database; import std.traits: isSomeFunction; Database db; static this() { db = Database(":memory:"); db.execute("CREATE TABLE foo (bar INTEGER UNIQUE)"); } void transaction(Callable)(Callable c) if(isSomeFunction!Callable) { db.execute("BEGIN"); scope(success) db.execute("COMMIT"); scope(failure) db.execute("ROLLBACK"); c(); } void main() { import std.stdio: writeln; try { transaction({ db.execute("INSERT INTO foo VALUES (2)"); db.execute("INSERT INTO foo VALUES (3)"); db.execute("INSERT INTO foo VALUES (4)"); db.execute("INSERT INTO foo VALUES (5)"); db.execute("INSERT INTO foo VALUES (6)"); throw new Exception("oops"); }); } catch(Exception e) {} transaction({ db.execute("INSERT INTO foo VALUES (2)"); db.execute("INSERT INTO foo VALUES (4)"); db.execute("INSERT INTO foo VALUES (6)"); }); auto results = db.execute("SELECT bar FROM foo"); foreach(row; results) { writeln(row[0]); } }
Re: foo => "bar" key/value literals in D!
On Tuesday, 24 May 2016 at 01:11:39 UTC, Meta wrote: Clever and terrible. Now just modify the code to generate a struct or class and you've invented new anonymous struct/object syntax. Indeed. Also, I think this has revealed a bug (or deficiency) in the compiler. If you put this inside the foreach loop: Right, I tried that too and it didn't work... and I think it should, since this is an alias argument instead of a runtime function pointer, the names should be available. I tried the low level is(foo params == __parameters) too to no avail, the compiler is the buggy one here rather than Phobos.
Re: foo => "bar" key/value literals in D!
On Monday, 23 May 2016 at 20:08:11 UTC, Daniel N wrote: This pull request just removes an intentional restriction and make this feature more easily accessible for meta-programming, so that not everyone has to reinvent the wheel in their own libraries. S I'm actually not entirely convinced on that change. Parameter names should *not* be part of a function pointer or delegate type - that's not supported and kinda randomly buggy to depend on (if the types match, the names might not: the compiler is free to reuse the structure for matching types which means the names you get might be the ones from a previous definition!) Alias arguments are IMO different though, because they aren't a function pointer/delegate type, they are actually a function symbol, just one that happens to be defined inline. They should work. But I think the restriction on delegates' parameter names is actually a good one, protecting you from bugs in more complex programs.
Better Voldemort types
Blog post on making Voldemort types without the disk-space issues: http://www.schveiguy.com/blog/2016/05/have-your-voldemort-types-and-keep-your-disk-space-too/ -Steve
[Issue 15568] Wrong contracts generated when compiled with -O
https://issues.dlang.org/show_bug.cgi?id=15568 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #2 from Walter Bright --- https://github.com/dlang/dmd/pull/5803 --
Re: Idea: swap with multiple arguments
On Monday, May 23, 2016 18:10:02 Steven Schveighoffer via Digitalmars-d wrote: > On 5/23/16 5:47 PM, Ali Çehreli wrote: > > On 05/23/2016 01:27 PM, Steven Schveighoffer wrote: > >> On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: > >>> So swap(a, b) swaps the contents of a and b. This could be easily > >>> generalized to multiple arguments such that swap(a1, a2, ..., an) > >>> arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do > >>> know applications for three arguments. Thoughts? -- Andrei > >> > >> One thing that screams out to me: this should be called rotate, not swap. > > > > Yes, rotate(), but then I would never remember what direction it rotates. > > Use the law of UFCS: > > x.rotate(y, z); // x-> y, y -> z, z -> x Hmmm. And I would have assumed that it rotated in the other direction. This is really going to need a very specific name like rotateLeft or rotateRight in order for it not to be error-prone. - Jonathan M Davis
[Issue 15619] [REG 2.066] Floating-point x86_64 codegen regression, when involving array ops
https://issues.dlang.org/show_bug.cgi?id=15619 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #6 from Walter Bright --- Doesn't seem like this should be too hard to fix - just save xmm6-7 for Win64 - why not just do it? --
Re: foo => "bar" key/value literals in D!
On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! --- void main() { import std.stdio; writeln(obj!( foo => "bar", baz => 12 )); } --- Prints out: { foo: bar baz: 12 } A few tweaks would make a whole loose typed hash thing more akin to Ruby or PHP than D. What's obj? Behold: string obj(T...)() { import std.conv, std.traits; string jsonResult = "{"; foreach(arg; T) { jsonResult ~= "\n\t"; // I don't know why the usual is(__parameters) trick // won't work here, but a stringof hack will! string hack = typeof(arg!string).stringof; import std.string; hack = hack[hack.indexOf("function(string ") + "function(string ".length .. $]; hack = hack[0 .. hack.indexOf(")")]; jsonResult ~= hack; jsonResult ~= ": "; jsonResult ~= to!string(arg("")); } jsonResult ~= "\n}"; return jsonResult; } As you probably know, D has a couple lambda literal syntaxes. One of these is the fat arrow, with a valid form of argument => return_expression. The compiler makes templates out of these when you pass them around and those templates contain the parameters, including the name, and are callable code (if instantiated with a concrete type). I was disappointed to see the ordinary reflection tools didn't work here - I know, I'm abusing the language - but the trusty old .stringof hack did! Combined with the magic knowledge that these things are templates, I instantiated them (tbh I was a bit surprised it actually let me!) and extracted the name of the argument. Then simply running it results in the value at runtime. Combining these with facilities for building values - here, I just did a string but it could be whatever - results in an array that almost looks like it was pulled from one of those dynamic languages. Complete program here (may include bug fixes made after posting this announcement): http://arsdnet.net/dcode/have_i_lost_my_marbles.d I might actually use this nasty trick in some of my ugly code. Clever and terrible. Now just modify the code to generate a struct or class and you've invented new anonymous struct/object syntax. Also, I think this has revealed a bug (or deficiency) in the compiler. If you put this inside the foreach loop: import std.traits; alias inst = arg!string; pragma(msg, ParameterIdentifierTuple!inst); It prints out `tuple("")` both times, meaning that for some reason it sees these lambdas as having no parameter names.
Re: foo => "bar" key/value literals in D!
On Tuesday, 24 May 2016 at 01:11:39 UTC, Meta wrote: Clever and terrible. Now just modify the code to generate a struct or class and you've invented new anonymous struct/object syntax. Also, I think this has revealed a bug (or deficiency) in the compiler. If you put this inside the foreach loop: import std.traits; alias inst = arg!string; pragma(msg, ParameterIdentifierTuple!inst); It prints out `tuple("")` both times, meaning that for some reason it sees these lambdas as having no parameter names. And looks like I filed a bug 2 years ago and then promptly forgot about it.
[Issue 15907] Unjustified "is not visible from module" deprecation warning when using getMember trait
https://issues.dlang.org/show_bug.cgi?id=15907 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com Assignee|nob...@puremagic.com|c...@dawg.eu --
[Issue 15941] [REG v2.069] rbtree no longer supports classes
https://issues.dlang.org/show_bug.cgi?id=15941 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #1 from Walter Bright --- The commit that added rbtree.toString: https://github.com/dlang/phobos/commit/0f05183f5c792ac3adbc50953a9639b0140a27fc --
[Issue 15918] [2.070] Results from findSplit can no longer be assigned to each other
https://issues.dlang.org/show_bug.cgi?id=15918 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com Assignee|nob...@puremagic.com|and...@erdani.com --
Re: Idea: swap with multiple arguments
On Mon, May 23, 2016 at 04:01:08PM -0400, Andrei Alexandrescu via Digitalmars-d wrote: > So swap(a, b) swaps the contents of a and b. This could be easily > generalized to multiple arguments such that swap(a1, a2, ..., an) > arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I > do know applications for three arguments. Thoughts? -- Andrei As others have said, 'swap' is a horrible name for this. I'd go with 'rotate', but then there's the question of which direction it rotates. Conceivably, it's equally valid for an to get a1, a1 to get a2, etc.. So 'rotateRight' would be most unambiguous, though a handful to type. T -- What's an anagram of "BANACH-TARSKI"? BANACH-TARSKI BANACH-TARSKI.
[Issue 16031] [REG2.071] dmd internal error when compiling druntime with PIC=1
https://issues.dlang.org/show_bug.cgi?id=16031 Walter Brightchanged: What|Removed |Added CC||bugzi...@digitalmars.com --- Comment #1 from Walter Bright --- (In reply to Martin Krejcirik from comment #0) > make -f posix.mak MODEL=32 DMD=../dmd/src/dmd PIC=1 What does the PIC=1 do? PIC isn't anywhere in posix.mak --
Re: Berlin D Meetup May 2016
On Friday, 20 May 2016 at 07:28:15 UTC, Stefan Koch wrote: Aww dammit, just missed my train. We started like one hour late because of some key issue, so next time you might want to join even if a bit later :)
Re: Need a Faster Compressor
Just a heads up on the LZ4. I have spent roughly 3 hours optimizing my decompresser. And while I had stunning success, a speed-up of about 400%. I am still about 600x slower then the C variant. It is still a mystery to me why that is :) Since the generated code both smaller and works almost without spills.
Re: Idea: swap with multiple arguments
On 5/23/16 6:22 PM, Andrei Alexandrescu wrote: On 05/23/2016 04:27 PM, Steven Schveighoffer wrote: On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei One thing that screams out to me: this should be called rotate, not swap. Problem is the usefulness peaks at 2-3 args, and for 2 and 3 arguments "rotate" is overkill. -- Andrei OK, let me rephrase. For 3 arguments, swap is a totally unintuitive name :) I personally think rotate is fine, is describing pretty much exactly what is happening, and scales well. But I guess there is some existing meaning in Phobos for it, so that may not fly. -Steve
Re: matrix library
On Monday, 23 May 2016 at 20:56:54 UTC, Edwin van Leeuwen wrote: There is also mir, which is working towards being a full replacement for blas: https://github.com/libmir/mir It is still under development, but I think the goal is to become the ultimate matrix library :) I am sorely tempted to use mir's MatrixView as the backend for the matrix slicing but don't know what else I might need from cblas, so maybe this will come later (especially when I figure out, or someone explains, what the proper resource/reference handling should be, especially in the case of small matrices backed by static arrays or something). Now I am thinking that the best way to orthogonalize (sorry) my efforts with respect to mir and scid.linalg is to use them as backend drivers, maintain this wrapper for the crowd that isn't as familiar with blas/lapack, or wants to write slightly more concise top-level code, and forward the relevant bug reports and pull requests to mir and scid.
Re: Need a Faster Compressor
On 5/23/2016 2:17 PM, Timon Gehr wrote: Then don't do that. I.e. re-mangle recursively from scratch for each mangled name and allow sharing parts between unrelated components within that mangled name. How is that essentially different from running a compression pass? The only real problem with the compressor was the compression speed, and the LZ4 test shows this is solvable. > (That's similar to how the compiler stores the structure in memory, which also avoids the exponential blowup.) No, it doesn't. You can't have exponential growth before compression. The compiler is designed so that the internal names are pretty much write-only, uniquely hashed by their address. It's not spending time running strlen()'s on them. Any scheme that does not prevent running time exponential in template instantiation depth is also inadequate in the long run. Most algorithms seem to have pathological worst cases, but as long as they are rare, it doesn't impede their utility.
Re: Idea: swap with multiple arguments
On Monday, 23 May 2016 at 21:47:31 UTC, Ali Çehreli wrote: Yes, rotate(), but then I would never remember what direction it rotates. If we take a cue from assembly instructions, there's rol and ror (rotate left/right). These are other instructions are normally unreachable in languages; Although it's usefulness can be wagered from time to time. There's also it's cousins rotate with carry (rcl and rcr).
Re: Idea: swap with multiple arguments
On 05/23/2016 04:27 PM, Steven Schveighoffer wrote: On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei One thing that screams out to me: this should be called rotate, not swap. Problem is the usefulness peaks at 2-3 args, and for 2 and 3 arguments "rotate" is overkill. -- Andrei
Re: faster splitter
On 05/23/2016 03:11 PM, qznc wrote: Actually, std find should be faster, since it could use the Boyer Moore algorithm instead of naive string matching. Conventional wisdom has it that find() is brute force and that's that, but probably it's time to destroy. Selectively using advanced searching algorithms for the appropriate inputs is very DbI-ish. There are a few nice precedents of blend algorithms, see e.g. http://effbot.org/zone/stringlib.htm. Writing a generic subsequence search blend algorithm, one that chooses the right algorithm based on a combination of static and dynamic decisions, is quite a fun and challenging project. Who wanna? Andrei
Re: Idea: swap with multiple arguments
On 5/23/16 5:47 PM, Ali Çehreli wrote: On 05/23/2016 01:27 PM, Steven Schveighoffer wrote: On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei One thing that screams out to me: this should be called rotate, not swap. Yes, rotate(), but then I would never remember what direction it rotates. Use the law of UFCS: x.rotate(y, z); // x-> y, y -> z, z -> x -Steve
Re: Idea: swap with multiple arguments
On Monday, 23 May 2016 at 20:01:08 UTC, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei It doesn't make sense for "swap" to make take than two arguments and it's unintuitive how it should rearrange the elements when you write swap(a1, a2, a3, ...). Who's to say that it should shift the elements to the left? I'm not saying this is useless but it would really need a better name. "swap" only makes intuitive sense when it takes two arguments, no more and no less. While this is technically a rotation, a "rotate" function generally takes an extra argument which is an element/index to rotate on. See: https://www.sgi.com/tech/stl/rotate.html
Re: Idea: swap with multiple arguments
On 05/23/2016 01:27 PM, Steven Schveighoffer wrote: On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei One thing that screams out to me: this should be called rotate, not swap. -Steve Yes, rotate(), but then I would never remember what direction it rotates. Ali
Re: Idea: swap with multiple arguments
On Monday, May 23, 2016 16:27:43 Steven Schveighoffer via Digitalmars-d wrote: > On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: > > So swap(a, b) swaps the contents of a and b. This could be easily > > generalized to multiple arguments such that swap(a1, a2, ..., an) > > arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do > > know applications for three arguments. Thoughts? -- Andrei > > One thing that screams out to me: this should be called rotate, not swap. That would probably be better. My immediate thought on reading Andrei's suggestion for swap was that it would be way too easy to forget what's actually being swapped when there are more than two arguments. Rotate at least implies and ordering to it. Though I confess that I've never heard of a swap function (or anything like a swap function) that's swapped more than two arguments, and I'm not aware of any point in time when I thought that such a thing might be useful. So, I'm not exactly clamoring for a function like this, but that obviously doesn't mean that it's not worth adding, just that I don't personally see any particular value in it. - Jonathan M Davis
Re: Idea: swap with multiple arguments
On Monday, 23 May 2016 at 20:27:43 UTC, Steven Schveighoffer wrote: On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei One thing that screams out to me: this should be called rotate, not swap. -Steve Just name Andrei's function rotate and make swap just an alias of it with exactly two parameters. No confusion and everyone is happy.
Re: Need a Faster Compressor
On 23.05.2016 22:34, Walter Bright wrote: On 5/23/2016 12:32 PM, Timon Gehr wrote: Instead, compression should be performed while generating the mangled string. The trouble with that is the mangled string is formed from component pieces. Then don't do that. I.e. re-mangle recursively from scratch for each mangled name and allow sharing parts between unrelated components within that mangled name. (That's similar to how the compiler stores the structure in memory, which also avoids the exponential blowup.) Those component pieces may have common substrings with each other, which won't be detected until they are merged, when you're back to dealing with the string as a whole. Isn't it enough to create references to previously embedded mangled symbols (i-th symbol already mangled) while generating the mangled string? That's been covered upthread, and VC++/g++ do that. But as shown, it is inadequate. There's a lot more redundancy than just the identifiers. Yes, but I think that should be covered (up to constants) by what I suggested above? You can't have exponential growth before compression. Any scheme that does not prevent running time exponential in template instantiation depth is also inadequate in the long run.
Re: Idea: swap with multiple arguments
On Monday, 23 May 2016 at 20:27:43 UTC, Steven Schveighoffer wrote: On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei One thing that screams out to me: this should be called rotate, not swap. -Steve Unless it swaps randomly :)
Re: matrix library
On Monday, 23 May 2016 at 20:27:54 UTC, Vlad Levenfeld wrote: On Monday, 23 May 2016 at 20:11:22 UTC, Vlad Levenfeld wrote: ... On first glance it looks like https://github.com/DlangScience/scid/blob/master/source/scid/matrix.d has most of what my matrix implementation is missing. Not sure how to put them together yet. There is also mir, which is working towards being a full replacement for blas: https://github.com/libmir/mir It is still under development, but I think the goal is to become the ultimate matrix library :)
Re: Could forum.dlang.org remember how many captchas I filled out?
On Monday, 23 May 2016 at 18:54:47 UTC, Joakim wrote: Hmm, I almost never get that CAPTCHA, and I don't log in to the forum. Could be something else about your profile that Akismet flags: have you tried taking it up with them? I login here, not with them. They can't tell who I'm logged in here as, I would assume. I can't expect them to make an exception for me if I'm not even logging in with them. Also, they're a huge, faceless corporation that heuristically targets spammers worldwide, and I don't like the idea of my activity being profiled worldwide. They do heuristic profiling anyway. They're not supposed to be relied upon as an ultimate authority on who's a spammer. A simple counter for how many captchas solved in a given login is way more reliable than pinging them for the answer every time.
Re: Need a Faster Compressor
On 5/23/2016 9:00 AM, Stefan Koch wrote: On Monday, 23 May 2016 at 15:33:45 UTC, Walter Bright wrote: Also, the LZ4 compressor posted here has a 64K string limit, which won't work for D because there are reported 8Mb identifier strings. This is only partially true. The 64k limit does not apply to the input string. The starting line of the compression function posted here tests for it and aborts if larger.
Re: Interest in Boston area D meetups?
On 5/23/16 2:50 PM, Steven Schveighoffer wrote: I think there is enough interest, well, at least a foursome. I will try and figure out something. Related: does anyone have a location preferably public transport accessible that would be good to host this? Email me (schvei...@yahoo.com) -Steve
Re: Need a Faster Compressor
On 5/23/2016 12:32 PM, Timon Gehr wrote: Instead, compression should be performed while generating the mangled string. The trouble with that is the mangled string is formed from component pieces. Those component pieces may have common substrings with each other, which won't be detected until they are merged, when you're back to dealing with the string as a whole. Isn't it enough to create references to previously embedded mangled symbols (i-th symbol already mangled) while generating the mangled string? That's been covered upthread, and VC++/g++ do that. But as shown, it is inadequate. There's a lot more redundancy than just the identifiers.
Re: DMD producing huge binaries
On 5/23/16 4:25 PM, Walter Bright wrote: On 5/23/2016 12:03 PM, Steven Schveighoffer wrote: Indeed, D does not overload based on return type ever. It does factor into type matching when a function pointer is used, for example. Yes, that may be the only time return type is factored in, but practically speaking, a function overload set that overloads solely on return type is not directly callable (you will get ambiguity error), so there is little point to create such a situation. -Steve
Re: Idea: swap with multiple arguments
On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei One thing that screams out to me: this should be called rotate, not swap. -Steve
Re: DMD producing huge binaries
On 5/23/2016 12:03 PM, Steven Schveighoffer wrote: Indeed, D does not overload based on return type ever. It does factor into type matching when a function pointer is used, for example.
Re: matrix library
On Monday, 23 May 2016 at 20:11:22 UTC, Vlad Levenfeld wrote: ... On first glance it looks like https://github.com/DlangScience/scid/blob/master/source/scid/matrix.d has most of what my matrix implementation is missing. Not sure how to put them together yet.
Re: Could forum.dlang.org remember how many captchas I filled out?
On Monday, 23 May 2016 at 17:56:17 UTC, cy wrote: I've filled out one of these for every post I've made here. I often get a CAPTCHA when I'm using a VPN at home.
Re: matrix library
On Monday, 23 May 2016 at 18:10:40 UTC, Carl Vogel wrote: How does what you're doing compare to what's in https://github.com/DlangScience/scid/blob/master/source/scid/linalg.d ? Basically, I have made a matrix structure and wrapped some basic arithmetic, while scid.linalg provides functions wrapping some heavier tasks (inversion, determinant, etc). There appears to be no functional overlap, and I think what I will do is contribute any actual linalg routines I write back to scid.linalg, and then import it as a dependency to this package. The stuff in my lib right now is way less careful wrt resources than scid.linalg and wouldn't serve as a general-purpose matrix wrapper. Maybe in enough iterations it will converge on something relatively performant. On Monday, 23 May 2016 at 18:10:40 UTC, Carl Vogel wrote: Making the dims template/compile-time params is an interesting choice, but I wonder if it is unduly limiting. Yeah, you are right. I mentioned dynamic-array-backed matrices as an efficiency thing in my first post but that would be a good way to solve this problem as well.
Re: Persistent object discussion
On Wednesday, 11 May 2016 at 01:25:39 UTC, Sergei Degtiarev wrote: I want to suggest an addition to standard library [...] The code is here: https://github.com/D-Programming-Language/phobos/pull/3625 , "perpetual" is the name of that novel you'll show to your literature teacher at Yale, but definitevely not the name of a Phobos module ;)
Re: faster splitter
On 05/23/2016 03:11 PM, Jack Stouffer wrote: (I think it's a micro optimization at best) splitter in the stdlib is likely to be very frequently useful, any bit of speedup we put in it is likely to pay off immensely. -- Andrei
Re: foo => "bar" key/value literals in D!
On Monday, 23 May 2016 at 19:00:40 UTC, Adam D. Ruppe wrote: Have I gone completely mad?!?! That makes two of us, I also use similar techniques. Please help argue in favour of pulling this: https://github.com/dlang/phobos/pull/3620/files https://issues.dlang.org/show_bug.cgi?id=13780 This pull request just removes an intentional restriction and make this feature more easily accessible for meta-programming, so that not everyone has to reinvent the wheel in their own libraries.
Re: Preprocessing CSS
On 05/23/2016 02:15 PM, Dmitry Olshansky wrote: On 23-May-2016 19:04, Andrei Alexandrescu wrote: Found this on reddit: http://blog.00null.net/post/144763147991/using-gnu-m4-as-a-css-pre-processor. I found it interesting because I found it useful to preprocess our style.css on dlang.org with ddoc. Somehow that got lost a while ago. How can I find the rename style.css -> style.css.dd and then back on github? Thx! -- Andrei Or just use SASS or LESS or any popular tool designed for CSS, no? I looked into those and they seemed to add additional dependencies for little else than what could be done with ddoc immediately. -- Andrei
Idea: swap with multiple arguments
So swap(a, b) swaps the contents of a and b. This could be easily generalized to multiple arguments such that swap(a1, a2, ..., an) arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do know applications for three arguments. Thoughts? -- Andrei
Re: Is NullableRef checked at compile time?
On 05/23/2016 08:10 PM, cy wrote: I was squinting at the std.typecons.NullableRef code and it _looks_ like isNull is only checked at runtime (and not checked at all in release mode!) but D has surprised me before in its ability to pre-calculate stuff during compilation. NullableRef is little more than a plain pointer. In particular, it allows nulling the reference. Guarding against null dereferences doesn't seem to be on its agenda at all. I was thinking of using something like this: http://arsdnet.net/dcode/notnullsimplified.d ...which does the check once (during runtime) but after that it's compile-time verified not to have a null pointer. (Sort of like C++ references!) I think using NullableRef instead would have every instance of getting the pointer perform the check at runtime, even if it has already been verified as not null. That's correct, right? Yes I know, premature optimization etc, but I was just curious if a NotNull template might be a stronger declaration of a pointer's nullness. Notice the different name. The goals of NotNull and NullableRef seem to be entirely different. Also note that NotNull uses `assert` for the check, too. So there's no check with -release either. Can easily change that to `enforce`, of course.
Struct literals and AA literals
Hi, Today I stumbled upon this weird error: struct ConfigContainer { Config[string] configs; } struct Config { string foo; string bar; } enum ConfigContainer cc = { configs: [// error: not an associative array initializer "MyConfig": { foo: "foo", bar: "bar" } ] }; But this other way works fine: enum ConfigContainer cc = { configs: [ "MyConfig": Config("foo", "bar") ] }; Is this a bug? Or is this by design? Thank you in advance. Lodovico Giaretta
Re: DMD producing huge binaries
On 5/23/16 3:03 PM, Steven Schveighoffer wrote: On 5/22/16 5:42 PM, Andrei Alexandrescu wrote: On 05/21/2016 03:13 PM, Kagamin wrote: On Saturday, 21 May 2016 at 18:18:21 UTC, Andrei Alexandrescu wrote: He said that that won't happen any longer, the growth was because of the return type. Is that correct? https://issues.dlang.org/show_bug.cgi?id=15831#c4 Looks like growth is due to the fact that the voldemort type is in the scope of a function and function is fun!(T).fun(T) - hence each level multiplies by 2. And return type is not part of the mangled name already - that would cause circular dependency, you would need the voldemort type mangling to generate it. Just to make sure I understand: do you agree or disagree that there's no more exponential growth if we encode "auto return" in the mangling? Thx! -- Andrei Not sure if someone has definitively answered before, but no, this does not. I think this would shrink the growth from 3^n to 2^n. To clarify, I think this is still a good idea, but only if the type is defined internally (no reason to repeat the entire function signature of the function you are defining). But if you specify auto return and return int, it should still be mangled as returning int. -Steve
Re: Is NullableRef checked at compile time?
On Monday, 23 May 2016 at 18:10:14 UTC, cy wrote: I was squinting at the std.typecons.NullableRef code and it _looks_ like isNull is only checked at runtime (and not checked at all in release mode!) but D has surprised me before in its ability to pre-calculate stuff during compilation. [...] NullableRef is checked at compile time only if you "hold the door".^^
Re: Need a Faster Compressor
On 22.05.2016 00:07, Walter Bright wrote: On 5/21/2016 2:37 PM, Timon Gehr wrote: Why is longest_match Ω(nm) instead of O(n+m) (e.g. KMP)? I don't understand the terms you use, but as to the "why" it is based on what I knew about LZ77 compression. I don't pretend to be an expert on compression, and this is what I churned out. As mentioned elsewhere, the C++ mangling scheme has a primitive and ineffective LZ77 scheme built in, so I wouldn't waste time on that. A quick google search on finding the longest match in a string did not turn up anything obvious. ... E.g. the Knuth-Morris-Pratt (KMP) string search algorithm can be modified to compute longest match instead of full match (as it just efficiently builds and runs a finite state machine whose state is the length of the longest match ending at the current position). https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm Implementation: auto longestMatch(string x,string y){ if(y.length>x.length) y=y[0..x.length]; auto f=new size_t[y.length+1]; for(size_t i=0,j=f[0]=-1;ir.length) r=x[i-j..i+1]; } return r; } This returns a slice of x representing the leftmost longest match with y. Running time is O(x.length). (In practice, if this should be really fast, the allocation for 'f' should probably be shared among multiple calls.) (This probably only improves running time in case there are sufficiently many sufficiently long matches.) But this just improves longest_match. It should be possible to bring down the running time of the entire compression algorithm significantly using a suffix tree (the resulting running time bound is linear in the input size and independent of the window size). If you want to throw your hat (i.e. expertise) into the ring and post a faster compressor, please do so! As far as I understand, the use case for this is compressing mangled names? I don't think that generating huge mangled names explicitly just to compress them afterwards is a viable strategy. This process throws away a lot of structure information during mangling that could be useful for fast and effective compression. Instead, compression should be performed while generating the mangled string. As far as I understand, mangled names only grow unmanageably large because the same symbols are mangled into them multiple times? Isn't it enough to create references to previously embedded mangled symbols (i-th symbol already mangled) while generating the mangled string?
Re: DMD producing huge binaries
On 5/23/16 3:03 PM, Steven Schveighoffer wrote: In fact, this may be a reason to NOT shortcut the return mangle (if you had compiled against foo one day, and foo's internal voldemort type changes the next, it would still link, even though the type may have changed). Actually, this is not true. It will only fail to link if the name of the internal type changes, or you return some other type :( -Steve
Re: Hide input string from stdin
On 5/22/16 10:12 PM, Era Scarecrow wrote: On Sunday, 22 May 2016 at 22:38:46 UTC, Michael Chen wrote: I tried to write a small program that receive string as password. However, I didn't find available library for hide input string, even in core library. Any suggestion? Hmmm if you don't mind flooding the console (with either a pattern or spaces or newlines), you could spawn a separate thread to spam the console until it gets the flag to quit... Certainly not the best idea, but it would work... (Probably). I admire your willingness to look at all approaches for this problem :) -Steve
Re: faster splitter
On Sunday, 22 May 2016 at 18:56:30 UTC, qznc wrote: On Monday, 4 March 2013 at 19:11:17 UTC, Steven Schveighoffer wrote: On Mon, 04 Mar 2013 12:35:23 -0500, Andrei Alexandrescuwrote: That's comparable, please file an enh request. http://d.puremagic.com/issues/show_bug.cgi?id=9646 I think the actual slow thing is std.find, which splitter uses. Benchmark: https://dpaste.dzfl.pl/1e31b6f95659 The output is: std findtook162167000 manual find took 99852000 Actually, std find should be faster, since it could use the Boyer Moore algorithm instead of naive string matching.
Re: faster splitter
On Monday, 23 May 2016 at 14:47:22 UTC, qznc wrote: I see three options: 1. Remove dead bookkeeping code 2. Implement back() and popBack() 3. Use alternative splitter implementation (and implement back() and popBack()) The third one would be the best, if it is really faster. If the performance is really a problem (I think it's a micro optimization at best), then the best option is not to violate DRY. Have a template parameter, std.typecons.Flag, to turn off the back and popBack. Don't have two functions that are 95% the same code like filter and filterBidirectional.
Re: DMD producing huge binaries
On 5/22/16 5:42 PM, Andrei Alexandrescu wrote: On 05/21/2016 03:13 PM, Kagamin wrote: On Saturday, 21 May 2016 at 18:18:21 UTC, Andrei Alexandrescu wrote: He said that that won't happen any longer, the growth was because of the return type. Is that correct? https://issues.dlang.org/show_bug.cgi?id=15831#c4 Looks like growth is due to the fact that the voldemort type is in the scope of a function and function is fun!(T).fun(T) - hence each level multiplies by 2. And return type is not part of the mangled name already - that would cause circular dependency, you would need the voldemort type mangling to generate it. Just to make sure I understand: do you agree or disagree that there's no more exponential growth if we encode "auto return" in the mangling? Thx! -- Andrei Not sure if someone has definitively answered before, but no, this does not. I think this would shrink the growth from 3^n to 2^n. The exponential growth happens because of the repeating of the template types. If you look at the example in the bug report, there is no return types anywhere. They exist in the mangled names, but are not relevant to the FQN or symbol resolution. The return type only plays a factor for preventing linking against other files that expect a certain return type. In fact, this may be a reason to NOT shortcut the return mangle (if you had compiled against foo one day, and foo's internal voldemort type changes the next, it would still link, even though the type may have changed). Indeed, D does not overload based on return type ever. -Steve
foo => "bar" key/value literals in D!
Have I gone completely mad?!?! --- void main() { import std.stdio; writeln(obj!( foo => "bar", baz => 12 )); } --- Prints out: { foo: bar baz: 12 } A few tweaks would make a whole loose typed hash thing more akin to Ruby or PHP than D. What's obj? Behold: string obj(T...)() { import std.conv, std.traits; string jsonResult = "{"; foreach(arg; T) { jsonResult ~= "\n\t"; // I don't know why the usual is(__parameters) trick // won't work here, but a stringof hack will! string hack = typeof(arg!string).stringof; import std.string; hack = hack[hack.indexOf("function(string ") + "function(string ".length .. $]; hack = hack[0 .. hack.indexOf(")")]; jsonResult ~= hack; jsonResult ~= ": "; jsonResult ~= to!string(arg("")); } jsonResult ~= "\n}"; return jsonResult; } As you probably know, D has a couple lambda literal syntaxes. One of these is the fat arrow, with a valid form of argument => return_expression. The compiler makes templates out of these when you pass them around and those templates contain the parameters, including the name, and are callable code (if instantiated with a concrete type). I was disappointed to see the ordinary reflection tools didn't work here - I know, I'm abusing the language - but the trusty old .stringof hack did! Combined with the magic knowledge that these things are templates, I instantiated them (tbh I was a bit surprised it actually let me!) and extracted the name of the argument. Then simply running it results in the value at runtime. Combining these with facilities for building values - here, I just did a string but it could be whatever - results in an array that almost looks like it was pulled from one of those dynamic languages. Complete program here (may include bug fixes made after posting this announcement): http://arsdnet.net/dcode/have_i_lost_my_marbles.d I might actually use this nasty trick in some of my ugly code.
Re: Could forum.dlang.org remember how many captchas I filled out?
On Monday, 23 May 2016 at 17:56:17 UTC, cy wrote: [...] I've filled out one of these for every post I've made here. Yet I'm logged in, with a persistent state on the server side. Could something be implemented along the lines of: [...] Hmm, I almost never get that CAPTCHA, and I don't log in to the forum. Could be something else about your profile that Akismet flags: have you tried taking it up with them?
Re: DMD producing huge binaries
On 5/19/16 6:17 PM, Walter Bright wrote: On 5/19/2016 8:39 AM, Steven Schveighoffer wrote: template(T) foo if (someConstraints) { struct Result { T t; } auto foo(T t) { return Result(t); } } This solution works awesomely, actually. It even produces smaller code than moving the struct completely outside. I'm going to use this mechanism in iopipe to get my voldemorts back :) Consider using a 'static struct'. A non-static struct will include a hidden member that points to the stack frame of foo(), i.e. "produces smaller code". Yes, I did use static in my actual code. In fact, I found a bug because of this (one of my voldemort functions was allocating a closure because I had thought I was using a member but was actually using a function parameter). But this doesn't fix the symbol size problem. The other mechanism does. -Steve
Re: Interest in Boston area D meetups?
On 5/22/16 5:00 PM, Sameer Pradhan wrote: On Tuesday, 17 May 2016 at 13:17:35 UTC, Steven Schveighoffer wrote: Is anyone interested in having D meetups in Boston area? I'm not familiar with really any other locals (well, there is one person I know of :) -Steve I would love to be part of the Boston D community. Maybe we can meet on/near the D line? Could not help making a pun. :-) Hehe, I think that goes to Riverside right? I remember taking that one into Boston many times as a kid :) I think there is enough interest, well, at least a foursome. I will try and figure out something. -Steve
Re: Chat with Stefan Koch about CTFE reimplementation
On Monday, 23 May 2016 at 16:32:30 UTC, deadalnix wrote: On Monday, 23 May 2016 at 15:57:42 UTC, rikki cattermole wrote: Hello! [...] Call me party pooper or something but this whole things seems to get way out of control. In order to asses the quality of the new design, one need to compare it to a baseline (aka the existing design) or one is basically going blind and unlikely to end up anywhere. There are obvious low hanging fruits in the existing design. For instance using a region allocator and blast it all after a CTFE run. It is like we have a car with square wheels, and you guys a reinventing a whole new car without even trying to maybe put round wheel on the existing one and see how it goes. Overall, that means you are embarking in an expensive project, with 0 visibility on the actual value provided. The maintainer of his own D frontend saying, "Let's not reinvent the car?" ;) You make a valid point, but part of the fun of open source is reinventing the wheel. Since that's what Stefan wants to do, let's hope he can get it done.
Re: missing data with parallel and stdin
On Monday, 23 May 2016 at 15:53:23 UTC, moechofe wrote: On Monday, 23 May 2016 at 14:16:13 UTC, Jack Stouffer wrote: Sounds like a data race problem. Use a lock on the file write operation and see if that helps. That didn't solve anything. What I observe is: when the process is slower, more files are copied. Last night I took the code sample and left copy out, everything else I got working. However when I ran it I noticed it's only running on one core and worked fine. However when I put in a number for how many to work on at once (adding any number to parallel's call) it would crash the program quite often, generally because it couldn't close files it was scanning. Looking over the documentation you appear to be using parallel correctly, so I don't know why it isn't working.
Re: Preprocessing CSS
On 23-May-2016 19:04, Andrei Alexandrescu wrote: Found this on reddit: http://blog.00null.net/post/144763147991/using-gnu-m4-as-a-css-pre-processor. I found it interesting because I found it useful to preprocess our style.css on dlang.org with ddoc. Somehow that got lost a while ago. How can I find the rename style.css -> style.css.dd and then back on github? Thx! -- Andrei Or just use SASS or LESS or any popular tool designed for CSS, no? -- Dmitry Olshansky
[Issue 16065] Provide digitally signed binaries for Windows
https://issues.dlang.org/show_bug.cgi?id=16065 James King <1...@lwshost.com> changed: What|Removed |Added CC||1...@lwshost.com --
[Issue 16065] New: Provide digitally signed binaries for Windows
https://issues.dlang.org/show_bug.cgi?id=16065 Issue ID: 16065 Summary: Provide digitally signed binaries for Windows Product: D Version: D2 Hardware: All OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: installer Assignee: nob...@puremagic.com Reporter: 1...@lwshost.com Hi all! Would it be possible to provide digitally signed binaries for the DMD Windows installers? Additionally, though this is likely outside the scope, perhaps [eventually] LDC and GDC installers could be hosted here as well [and signed]? Currently they are delivered over HTTP, and there is no way to be certain that the files truly originated from the downloads.dlang.org server or somewhere else. Even if HTTPS and HSTS were made available, this wouldn't protect users in a hypothetical scenario where the web server itself was compromised or where a Man-in-the-Middle attack had replaced the D website with another website that had a 'valid certificate' issued by another CA. I realize that this may be tricky to add into the build/release process, as protecting the signing key now becomes a critical issue, but I wanted to bring it up as I saw no previous or existing issues that covered this topic. Thank you for your consideration. --
Is NullableRef checked at compile time?
I was squinting at the std.typecons.NullableRef code and it _looks_ like isNull is only checked at runtime (and not checked at all in release mode!) but D has surprised me before in its ability to pre-calculate stuff during compilation. I was thinking of using something like this: http://arsdnet.net/dcode/notnullsimplified.d ...which does the check once (during runtime) but after that it's compile-time verified not to have a null pointer. (Sort of like C++ references!) I think using NullableRef instead would have every instance of getting the pointer perform the check at runtime, even if it has already been verified as not null. That's correct, right? Yes I know, premature optimization etc, but I was just curious if a NotNull template might be a stronger declaration of a pointer's nullness.
Re: matrix library
On Monday, 23 May 2016 at 07:28:20 UTC, Vlad Levenfeld wrote: https://github.com/evenex/linalg I've some heard people (including me) asking about matrix libraries for D, and while there is gl3n it only goes to 4x4 matrices and was written before all the multidimensional indexing stuff. So I was using gl3n for awhile until I needed some 6x6s and threw together a syntax-sugary sort of wrapper over std.experimental.ndslice and cblas for matrix math. You can slice submatrices, assign to them, and perform ops on them with other matrices or 2-dimensional array slices... though, for implementation-ish reasons, ops involving 2-d arrays are elementwise (you'll have to call the Matrix constructor to use matrix multiplication again). It was built in kind of an ad-hoc way and I will be adding stuff to it as the need arises, so there's nothing there yet beyond the bare basics and you should expect bugs. All the matrices hold static arrays because I don't want to mess with reference problems right now. A matrix past a certain size will be more efficient to store as a dynamic array, of course. But, right now, I need this to make writing linear algebra code comfortable for myself rather than try to win at benchmarks. Bugs/Pull/Feature requests welcome. This is nice! I recently found myself having to make ad hoc lightweight matrix classes that wrap some blas functions. Making the dims template/compile-time params is an interesting choice, but I wonder if it is unduly limiting. How does what you're doing compare to what's in https://github.com/DlangScience/scid/blob/master/source/scid/linalg.d ? While that project doesn't have a ton of manpower behind it, it does seem like it's actively maintained, and they have brought in a ton of the lapack/blas headers already. It would be nice, and I think do-able, to have a relatively complete and performant library for matrices/ndarrays, especially given the recent work on ndslice. (If there are plans or a roadmap for this sort of thing, I'd love to contribute, and it seems from this announcement that others are interested also.)
Could forum.dlang.org remember how many captchas I filled out?
Akismet thinks your post looks like spam. Please solve a CAPTCHA to continue. I've filled out one of these for every post I've made here. Yet I'm logged in, with a persistent state on the server side. Could something be implemented along the lines of: ALTER TABLE users ADD COLUMN num_captchas_solved INTEGER DEFAULT 0 NOT NULL ETC; I can understand if even an ordinary user like myself could be suspected of spam. The Internet doesn't make it easy to distinguish in a lot of cases. But my account login status does. If you made it so someone solving 12 captchas didn't get asked any more (until they actually start sending spam), that'd be really nice. You could even award achievements! (Achievement unlocked: On Fire. 100 posts in a week? Jeezus!) Not sure if this is the right place to ask, but this is regarding the posting server on forums.dlang.org, which I use to access all these mailing lists and such, without getting all the messages in all the lists sent to my email inbox.
Re: Speed up `dub`.
On Thursday, 19 May 2016 at 17:50:44 UTC, ciechowoj wrote: dub build --nodeps I tried it, doesn't seem to do anything, maybe something is broken. Perhaps you didn't complete "dub build" without --nodeps beforehand? You have to do that once, and it's still as annoyingly inefficient as anything, especially since it checks dependencies online even if you have the selected version downloaded already. But after that first compile, I add --nodeps to the dub build command, and it's lightning fast to recompile. It doesn't fix the issues in DUB that slow down compiling programs, but it does speed up the compile-modify-check cycle.
Re: aliasing expressions and identifiers
On Monday, 23 May 2016 at 15:18:51 UTC, Nick Treleaven wrote: If we had local refs, we could use this instead: ref m = matrix.rawArr; The difference is m is already computed, it is not recomputed each time m is read, unlike M(). I think the reason D doesn't support local refs is because it would make it harder to design @safe, particularly with the planned @rc ref-counting. Because M() above is only a return reference, it can't live longer than the data it references. My ref m could persist longer than matrix.rawArr using (naive) reference counting. BTW local refs are possible in @system code: http://forum.dlang.org/post/lmuokynffgljzvrpv...@forum.dlang.org Just to be clear: I'm not looking for anything touching the semantics, just a simple replacement mechanism/macro expansion. Recomputation or not, @safe or @system, should be no different from the expanded code. So within a scope, after aliasing 'm', 'm' should be replaced by 'matrix.rawArr'. Everything stays the same as is, even error messages. { // Some scope alias i = instance.targetIdx; alias m = matrix.rawArr; m[i] = m[j] + m[k]; // detected and conceptually replaced in one of the earlier compiler passes by // matrix.rawArr[instance.targetIdx] = matrix.rawArr[j] + matrix.rawArr[k] }
Re: Release DUB 0.9.25, new logo and updated website design
Am 23.05.2016 um 17:55 schrieb Luís Marques: On Sunday, 22 May 2016 at 19:36:39 UTC, Sönke Ludwig wrote: In preparation to that, it also received a thorough optical overhaul. The newly designed logo (which has appeared in some other spots already) has been integrated on the package registry, and the site style has been adjusted to fit the general dlang.org design (thanks to Sebastian Wilzbach!). Shouldn't the dub command-line interface documentation be part of the "Documentation" menu pop-down? Right now we have to go to: Header -> Documentation -> Getting Started -> Scroll down past lots of text -> Command line interface Yes, actually I had committed that change already, and just didn't rebuild the site yet :) Also, a minor improvement might be to: 1) have examples in the dub command line interface. E.g. after the general usage fixed-width block, have something simple like a sequence of dub build, dub run, etc, for those that are just skimming the documentation and just want to get the general ideia. In the build section have a simple example followed by a more complex one which shows the more advanced use cases, and so on. 2) have more context of what some of the options are. People might read, say, the documentation of --build and see the option of ddox but have no idea what that is/means. The information is currently procedurally generated from the CLI --help (queried from the dub library), so most improvements should probably happen in that area. But adding some extra introduction/examples to the global section would of course fit well in the web page template, too.
Re: aliasing expressions and identifiers
On Monday, 23 May 2016 at 15:18:51 UTC, Nick Treleaven wrote: On Monday, 23 May 2016 at 14:05:43 UTC, deed wrote: Some thoughts about extending the with-statement were brought up here earlier: http://forum.dlang.org/post/txpifmwpmmhsvcpbc...@forum.dlang.org I don't care much whether it would be with, alias or possibly something clever already existing, but a solution should be easy to use, easy to read and shouldn't introduce any possible overhead at runtime. From the linked thread: ref M() { return matrix.rawArr; } ref Ex1() { return e1.someProperties.someModulusX; } If we had local refs, we could use this instead: ref m = matrix.rawArr; Note that this wouldn't work with rvalues, which `with` supports. The difference is m is already computed, it is not recomputed each time m is read, unlike M(). I think the reason D doesn't support local refs is because it would make it harder to design @safe, particularly with the planned @rc ref-counting. Because M() above is only a return reference, it can't live longer than the data it references. My ref m could persist longer than matrix.rawArr using (naive) reference counting. At some point during the `scope` discussion, Walter wanted to allow local `ref`s, so I guess he's not opposed to the idea. As far as I understand, the compiler already supports them internally, as they can result from lowering certain constructs, there's just no syntax for them. They wouldn't pose a problem for lifetime tracking, because they can never be assigned to, only initialized once.
Re: Chat with Stefan Koch about CTFE reimplementation
On Monday, 23 May 2016 at 16:32:30 UTC, deadalnix wrote: It is like we have a car with square wheels, and you guys a reinventing a whole new car without even trying to maybe put round wheel on the existing one and see how it goes. I this particular model of car. The bolts of the wheels are on the inside. And you have to dismantle almost everything to change them.
Re: Chat with Stefan Koch about CTFE reimplementation
On Monday, 23 May 2016 at 16:32:30 UTC, deadalnix wrote: On Monday, 23 May 2016 at 15:57:42 UTC, rikki cattermole wrote: Hello! [...] Call me party pooper or something but this whole things seems to get way out of control. In order to asses the quality of the new design, one need to compare it to a baseline (aka the existing design) or one is basically going blind and unlikely to end up anywhere. There are obvious low hanging fruits in the existing design. For instance using a region allocator and blast it all after a CTFE run. It is like we have a car with square wheels, and you guys a reinventing a whole new car without even trying to maybe put round wheel on the existing one and see how it goes. Overall, that means you are embarking in an expensive project, with 0 visibility on the actual value provided. I get your point. However to stick with your car metaphor. We have a car with square wheels and a weak frame. As soon as round wheels enable it to go faster something else will give. Also I don't want a car. I want a rocket.
Re: Need a Faster Compressor
Am Mon, 23 May 2016 12:04:48 + schrieb Stefan Koch: > The method for archiving perfect compression it outlined here: > https://github.com/Cyan4973/lz4/issues/183 Nice, if it can keep the compression speed up. -- Marco
Re: Release DUB 0.9.25, new logo and updated website design
On Mon, 2016-05-23 at 17:40 +0200, Sönke Ludwig via Digitalmars-d- announce wrote: > > Oh, okay, misunderstood that. The basic protocol is very simple: My fault, I rushed my original email and didn't set out the problem properly. > GET /packages/index.json > Yields a JSON array with all package names > > GET /packages/[package].json > Returns a JSON object with general information about a package, > including all available versions > > GET /packages/[package]/[version].json > Returns a JSON object with the package recipe of a particular > version > (dub.json format), augmented with some additional fields > > GET /packages/[package]/[version].zip > Yields a zipped up version of the package Sponditious. I will see if I can query the server to create a suitable dictionary each time so as to avoid caching results, or whether caching and updating is necessary. > > There is also a separate search API (and some other less interesting > APIs): > > GET /api/packages/search?q=... > > > We should really get that written down on a web page... The above is close to all that is needed for those of us want an API for working with a running server. I might even use this is Python Workshops for testing HTTP APIs. :-) -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465 077 xmpp: rus...@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder signature.asc Description: This is a digitally signed message part
Re: Need a Faster Compressor
On Monday, 23 May 2016 at 16:00:20 UTC, Stefan Koch wrote: On Monday, 23 May 2016 at 15:33:45 UTC, Walter Bright wrote: Also, the LZ4 compressor posted here has a 64K string limit, which won't work for D because there are reported 8Mb identifier strings. This is only partially true. The 64k limit does not apply to the input string. It does only apply to the dictionary.It would only hit if we find 64k of identifier without repetition. If you want speed: 16k (aka half of the L1D).
Re: Chat with Stefan Koch about CTFE reimplementation
On Monday, 23 May 2016 at 15:57:42 UTC, rikki cattermole wrote: Hello! [...] Call me party pooper or something but this whole things seems to get way out of control. In order to asses the quality of the new design, one need to compare it to a baseline (aka the existing design) or one is basically going blind and unlikely to end up anywhere. There are obvious low hanging fruits in the existing design. For instance using a region allocator and blast it all after a CTFE run. It is like we have a car with square wheels, and you guys a reinventing a whole new car without even trying to maybe put round wheel on the existing one and see how it goes. Overall, that means you are embarking in an expensive project, with 0 visibility on the actual value provided.
Re: Diamond - MVC / Template engine
On Saturday, 21 May 2016 at 08:20:00 UTC, Bauss wrote: For more information please view below. Dub repository: https://code.dlang.org/packages/diamond Github: https://github.com/bausshf/Diamond The dub repository seems to have a problem properly escaping your example template. Could you check on that, and if the problem is on the dub registry create a bug report there?
Preprocessing CSS
Found this on reddit: http://blog.00null.net/post/144763147991/using-gnu-m4-as-a-css-pre-processor. I found it interesting because I found it useful to preprocess our style.css on dlang.org with ddoc. Somehow that got lost a while ago. How can I find the rename style.css -> style.css.dd and then back on github? Thx! -- Andrei
Re: Hide input string from stdin
On Monday, 23 May 2016 at 15:56:14 UTC, Wyatt wrote: On Sunday, 22 May 2016 at 22:38:46 UTC, Michael Chen wrote: I tried to write a small program that receive string as password. However, I didn't find available library for hide input string, even in core library. Any suggestion? For Linux, I think you could just use getpass() from core.sys.posix.unistd. Not sure what the Windows equivalent is. An agnostic, user-facing version isn't a terrible idea. Or arguably better, a good way to disable echo on stdin; maybe file a bug about this against std.stdio? -Wyatt Here's example `getpass` (in C++, but can be translated trivially) for Windows, using `SetConsoleMode` with turning off `ENABLE_ECHO_OUTPUT`. http://www.cplusplus.com/articles/E6vU7k9E/#WIN-e1
Re: Need a Faster Compressor
On Monday, 23 May 2016 at 15:33:45 UTC, Walter Bright wrote: Also, the LZ4 compressor posted here has a 64K string limit, which won't work for D because there are reported 8Mb identifier strings. This is only partially true. The 64k limit does not apply to the input string. It does only apply to the dictionary.It would only hit if we find 64k of identifier without repetition.
Chat with Stefan Koch about CTFE reimplementation
Hello! So on today's stream[0] I had a chat with Stefan and worked through a few problems regarding reimplementation of dmd's CTFE. So a TLDR for those who do not wish to watch the video. - ddmd.dinterpret will have only two public free-functions (ctfeInterpret and ctfeInterpretForpragmaMsg). - For this, CompiledCtfeFunction struct will be removed from FuncDeclaration (.ctfeCode). The suggested fix is by using a hash table in dinterpret. - extern (C++) Expression getValue(VarDeclaration vd). Will no longer be used as is in ddmd.ctfeexpr. - printCtfePerformanceStats will be deleted altogether. - Everything else is essentially (or will be) private. Please note that these are not final, it is just the solutions we found during the stream in isolating dinterpret to itself. The benefits to this is of course, the implementation of CTFE will not publically expose its inner workings. Meaning if it is desired, it can be concurrent or JIT'd. Finally a question from Stefan, how much does dinterpret actually need the backend for transiently? We know from looking that it doesn't appear to use it in at least 2 degrees of separation. Please note that I do not intend for this video to get posted on Reddit since its about dmds internals (and not very important). [0] https://www.livecoding.tv/alphaglosined/videos/radD5-talking-with-stefan-koch-about-dmd
Re: Hide input string from stdin
On Sunday, 22 May 2016 at 22:38:46 UTC, Michael Chen wrote: I tried to write a small program that receive string as password. However, I didn't find available library for hide input string, even in core library. Any suggestion? For Linux, I think you could just use getpass() from core.sys.posix.unistd. Not sure what the Windows equivalent is. An agnostic, user-facing version isn't a terrible idea. Or arguably better, a good way to disable echo on stdin; maybe file a bug about this against std.stdio? -Wyatt
Re: Release DUB 0.9.25, new logo and updated website design
On Sunday, 22 May 2016 at 19:36:39 UTC, Sönke Ludwig wrote: In preparation to that, it also received a thorough optical overhaul. The newly designed logo (which has appeared in some other spots already) has been integrated on the package registry, and the site style has been adjusted to fit the general dlang.org design (thanks to Sebastian Wilzbach!). Shouldn't the dub command-line interface documentation be part of the "Documentation" menu pop-down? Right now we have to go to: Header -> Documentation -> Getting Started -> Scroll down past lots of text -> Command line interface Also, a minor improvement might be to: 1) have examples in the dub command line interface. E.g. after the general usage fixed-width block, have something simple like a sequence of dub build, dub run, etc, for those that are just skimming the documentation and just want to get the general ideia. In the build section have a simple example followed by a more complex one which shows the more advanced use cases, and so on. 2) have more context of what some of the options are. People might read, say, the documentation of --build and see the option of ddox but have no idea what that is/means.
Re: missing data with parallel and stdin
On Monday, 23 May 2016 at 14:16:13 UTC, Jack Stouffer wrote: Sounds like a data race problem. Use a lock on the file write operation and see if that helps. Like this?: synchronized(mutex) copy(source,dest); That didn't solve anything. What I observe is: when the process is slower, more files are copied.
Re: Release DUB 0.9.25, new logo and updated website design
Am 23.05.2016 um 17:31 schrieb Dicebot: On Monday, 23 May 2016 at 15:13:56 UTC, Russel Winder wrote: My need is two write a Python program that queries the running Dub repository. So I am guessing this is an HTTP-based protocol. I guess I will have to read the Dub code and deduce/infer/guess the necessary protocol. Not a problem, but it would have been easier for me not to have to do this but to have the API. Is there a repository with the beginnings of something that I might contribute to? Here is the declaration of REST API : https://github.com/dlang/dub-registry/blob/master/source/dubregistry/api.d#L21-L39 For example: http://code.dlang.org/api/packages/dub/info Just to explain the context. The original API was made in a way that any simple webserver with file serving support could be used as a valid package registry. The REST API is newer and has a broader scope. For any tool that wants to be as compatible as possible with registries other than code.dlang.org, using the original API would be the better choice. If that's not a concern, using the /api/* endpoints is just as good and offers some more possibilities.
Re: Release DUB 0.9.25, new logo and updated website design
Am 23.05.2016 um 17:13 schrieb Russel Winder via Digitalmars-d-announce: On Mon, 2016-05-23 at 15:19 +0200, Sönke Ludwig via Digitalmars-d- announce wrote: Am 23.05.2016 um 15:01 schrieb Russel Winder via Digitalmars-d- announce: Hi, Is the Dub API published anywhere. I propose to write a dmd/ldc/gdc subtool so that dependency management based on the Dub repository is provided for SCons D builds. Online docs are still on the TODO list, but you can do dub fetch dub dub run dub -b ddox And it will start up a local HTTP server on http://127.0.0.1:8080/ with the API documentation. I think I have not expressed my needs as I intended. The above is about the code that runs, I am more interested in the way of interacting with a running server. I appreciate this latter is (sort of) contained in the former, but I think they are two different needs and so require different documentation. It sounds as though all forms of documentation are on the "not done yet" which is understandable. My need is two write a Python program that queries the running Dub repository. So I am guessing this is an HTTP-based protocol. I guess I will have to read the Dub code and deduce/infer/guess the necessary protocol. Not a problem, but it would have been easier for me not to have to do this but to have the API. Is there a repository with the beginnings of something that I might contribute to? Oh, okay, misunderstood that. The basic protocol is very simple: GET /packages/index.json Yields a JSON array with all package names GET /packages/[package].json Returns a JSON object with general information about a package, including all available versions GET /packages/[package]/[version].json Returns a JSON object with the package recipe of a particular version (dub.json format), augmented with some additional fields GET /packages/[package]/[version].zip Yields a zipped up version of the package There is also a separate search API (and some other less interesting APIs): GET /api/packages/search?q=... We should really get that written down on a web page...
Re: Need a Faster Compressor
On 5/23/2016 5:04 AM, Stefan Koch wrote: Am Sun, 22 May 2016 23:42:33 -0700 schrieb Walter Bright: The file format: http://cyan4973.github.io/lz4/lz4_Block_format.html It doesn't look too difficult. If we implement our own LZ4 compressor based on that, from scratch, we can boost license it. That it right. It's pretty simple. Also, the LZ4 compressor posted here has a 64K string limit, which won't work for D because there are reported 8Mb identifier strings.