Re: module `socket` is in file 'std/c/linux/socket.d' which cannot be read

2018-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 3 August 2018 at 16:41:09 UTC, bachmeier wrote: 2.081.1 huh, it works for me... you on Linux or some other system? The embedded_httpd_processes version is Linux specific, on other OSes it uses threads...

Re: module `socket` is in file 'std/c/linux/socket.d' which cannot be read

2018-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 3 August 2018 at 16:51:37 UTC, bachmeier wrote: I'm running Ubuntu 16.04. OK, I see it now, I had another .di file on my system than the stock one. Pushed a new version to git, it needs to also import a second module import core.sys.posix.netinet.in_; t

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 3 August 2018 at 16:58:26 UTC, kdevel wrote: What does auto std.stdio.File.ByChunkImpl byChunk ( ulong chunkSize ); on https://dlang.org/library/std/stdio/file.by_chunk.html mean? It looks like ddox trying to tell you what the auto actually is. But it returns a ByChunkIm

Re: What does auto std.stdio.File.ByChunkImpl byChunk (ulong chunkSize ); mean?

2018-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 3 August 2018 at 17:16:14 UTC, kdevel wrote: But that indented "code" is not syntactically valid D. Isn't it? Right, it would give an error if actually compiled. But remember, this is documentation that just happens to look like code, so it is intended to be legible by people rathe

Re: Slicing betterC

2018-09-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 September 2018 at 17:10:49 UTC, Oleksii wrote: struct Slice(T) { size_t capacity; size_t size; T* memory; } There's no capacity in the slice, that is stored as part of the GC block, which it looks up with the help of RTTI, thus the TypeInfo reference. Slices *just*

Re: Pass 'this' as reference

2018-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 12 September 2018 at 15:01:36 UTC, Jan wrote: I'm using D not for that long and lately I have encountered an issue. I have class 'Foo' with a constructor using this signature: `this (ref Bar original)` classes and the ref keyword should very rarely be used together in D. classe

Re: remove file access denied(remove broke)

2018-09-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 14 September 2018 at 08:32:48 UTC, Josphe Brigmo wrote: Seems remove is broke. The source code for remove is DeleteFile(name), so not much room for bugs there, except maybe string conversion. What is the filename you are working on?

Re: Why do some attributes have an @ symbol and others don't?

2018-09-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 September 2018 at 12:40:07 UTC, Gary Willoughby wrote: Is it just a legacy thing? Yeah, basically the ones that date back to before the @ thing don't have it, and the ones after it do.

Re: std.process.execute without capturing stderr?

2018-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 21 September 2018 at 06:08:39 UTC, berni wrote: Sorry, I made a mistake while testing and after I found out, that it was not available in the documentation at dpldocs.info I concluded, that it must be a really new feature. But now it seems to me, that dpldocs is outdated a little bit

Re: "Error: function expected before (), not module *module* of type void

2018-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 22 September 2018 at 01:51:33 UTC, Samir wrote: main.d: import isPrime; void main() { isPrime(x); } You probably shouldn't name a module the same as a member anyway, and it should also have two names, like "module myproject.isprime;" But the fix here is to just use the full

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 26 September 2018 at 20:41:38 UTC, Chad Joan wrote: I'm implementing a deep-copy method for a tree of templated class instances. As part of this, I need some way to copy each node. [...] that isn't already handled by their deepCopy method. I would strongly suggest just using th

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 September 2018 at 05:18:14 UTC, Chad Joan wrote: How does this work? The language reference states that typeid(Type) returns "an instance of class TypeInfo corresponding to Type". (https://dlang.org/spec/expression.html#typeid_expressions) But then the TypeInfo class doesn't s

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 September 2018 at 05:04:09 UTC, Chad Joan wrote: The tree nodes are potentially very diverse, but the tree structure itself will be very homogeneous. The virtual method can still handle that case! But, if your child array of expressions is already accessible through the base i

Re: Can I create static c callable library?

2018-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 September 2018 at 21:41:31 UTC, H. S. Teoh wrote: Though I'm not sure what will happen if your C program tries loading two or more D libraries that use this trick... is rt_init() idempotent? It just refcounts itself.

Re: Prevent opening binary/other garbage files

2018-09-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 29 September 2018 at 15:52:30 UTC, helxi wrote: I'm writing a utility that checks for specific keyword(s) found in the files in a given directory recursively. What's the best strategy to avoid opening a bin file or some sort of garbage dump? Check encoding of the given file? Simp

Re: Prevent opening binary/other garbage files

2018-09-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 29 September 2018 at 23:46:26 UTC, helxi wrote: Thanks. Would you say https://dlang.org/library/std/encoding/get_bom.html is useful in this context? Eh, not really, most text files will not have one.

Re: Does the WInMain function is mandatory ?

2018-09-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 30 September 2018 at 06:56:41 UTC, bauss wrote: There is function that does it for you called toStringz() https://dlang.org/library/std/string/to_stringz.html Not really best for Windows. That's for calling C functions with char*, for Windows, you should be working with wchar* inst

Re: Does the WInMain function is mandatory ?

2018-09-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 30 September 2018 at 13:17:33 UTC, Vinod K Chandran wrote: Thanks for the reply. But it says "toUTFz" is not defined. do i missing any import statement ? import std.utf;

Re: Prevent opening binary/other garbage files

2018-10-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 1 October 2018 at 15:21:24 UTC, helxi wrote: I tried out https://dlang.org/library/std/utf/validate.html before manually checking for encoding myself so I ended up with the code below. I was fairly surprised that "*.o" (object) files are UTF encoded! Is it normal? Yes. Any random c

Re: Dynamic Minimum width with Format / writefln

2018-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 00:14:03 UTC, Chris Katko wrote: Except it doesn't work and tries to decode col.width-1 into a hexadecimal number and only prints that. ("4D6EF6") That number certainly isn't col.width (unless you have a width of like millions)... It looks more like a pointer.

Re: Dynamic Minimum width with Format / writefln

2018-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 01:14:24 UTC, Chris Katko wrote: I'm not sure how I made this mistake. But it seems to only show up now if I leave .toStringz() with the writefln. Yeah. So what's happening here is toStringz returns the C-style char*, which printf works well with, but writef do

Re: std.socket tutorials? examples?

2018-10-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 4 October 2018 at 08:32:13 UTC, Chris Katko wrote: I've been Google'ing and there's like... nothing out there. My book has a few examples https://www.packtpub.com/application-development/d-cookbook of course, buying it for just std.socket (which is just like one page out of the

Re: Is there a function for this?

2018-10-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 6 October 2018 at 13:17:22 UTC, bauss wrote: My first thought was "uniq", but it can't really do it like that, but it doesn't work. uniq needs it to be sorted first, it only compares side-by-side (to avoid allocating space to remember what it has already seen) Is there another

Re: Can't Compile Global Semaphores?

2018-10-08 Thread Adam D. Ruppe via Digitalmars-d-learn
I recently rewrote some of my threading code in cgi.d and used the core.sync.semaphore with core.threads... never once used shared or __gshared. I just passed the handle of the semaphore to the new thread constructor. All seems to work.

Re: std.regex is fat

2018-10-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 October 2018 at 03:07:59 UTC, Chris Katko wrote: For comparison, I just tested and grep uses about 4 MB of RAM to run. Running and compiling are two entirely different things. Running the D regex code should be comparable, but compiling it is slow, in great part because of inter

Re: std.regex is fat

2018-10-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 October 2018 at 02:44:55 UTC, Chris Katko wrote: So wait, if their solution was to simply REMOVE std.regex from isEmail. That was ctRegex, which is different than regex. That doesn't solve the regex problem at all. And from what I read in that thread, this penalty is paid per te

Re: Why doesn't foreach support iterating?

2018-10-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 01:17:40 UTC, Chris Katko wrote: I finally noticed in the docs it says "for arrays only." The question is, why? foreach for user-defined types only allow arguments that match what the user defined. Ranges typically do not define this (since it generally doesn'

Re: why is the default floating point value NAN ?

2018-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 October 2018 at 15:48:16 UTC, Codifies wrote: I'd have thought it ought to be 0.0 ? So far I seen carefully considered and sensible reasons for doing things in D, so why NAN ? You are supposed to initialize your own variables explicitly. NaN is a somewhat easy way to indicat

Re: How to store unique values of array in another array

2018-10-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 18 October 2018 at 18:39:18 UTC, Samir wrote: which leads me to believe that the output of `uniq` is not necessarily another integer array. Right, it is actually a "range" - an object that generates the result on-demand, so it doesn't do work you don't actually need. If you don't

Re: How to store unique values of array in another array

2018-10-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 18 October 2018 at 19:19:53 UTC, Samir wrote: They both seem to work. Is one preferred over the other? No difference. The compile will just transform o.f into f(o) if it can. They both do the same thing and it is just a different way of writing it. Which is better simply depen

Re: Path.GetDirectoryName for D?

2018-10-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 18 October 2018 at 19:54:59 UTC, Dr.No wrote: Are there a function like C#'s Path.GetDirectoryName() Looks the same as "dirName" from "import std.path" http://dpldocs.info/experimental-docs/std.path.dirName.1.html

Re: assigment to null class object member compiled? is this a bug?

2018-10-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 October 2018 at 06:53:32 UTC, dangbinghoo wrote: why the code bellow compiles? D compilers are allowed to make that an error, but it might not. With the current implementation, dmd that.d will compile, but dmd -O that.d will fail with an error. Yes, turning on optimizations h

Re: Built-in array opSliceAssign

2018-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 25 October 2018 at 12:25:37 UTC, Eduard Staniloiu wrote: IMHO, this is a bug. The code should lower to calls to opAssing for types that define opAssign. The spec doesn't exactly say it uses memset, but it does imply it: https://dlang.org/spec/arrays.html#array-copying talking abo

Re: Built-in array opSliceAssign

2018-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 25 October 2018 at 19:56:18 UTC, Stanislav Blinov wrote: The current behavior of the compiler is quite the opposite of those "same as" above. Yeah, I guess I am maybe selectively reading the spec in light of the implementation... but I think the examples are just sloppy. Or maybe

Re: getting Win32 Messagebox to work

2018-10-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 October 2018 at 12:56:21 UTC, rikki cattermole wrote: MessageBoxA(null, cast(const(char)*)content.ptr, cast(const(char)*)"Window title".ptr, 0); Get rid of those casts, they are unnecessary.

Re: getting Win32 Messagebox to work

2018-10-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 October 2018 at 13:13:07 UTC, Mark Moorhen wrote: But how would you do this without casts? If that doesn't compile without casts, you don't want it to compile - casting is often a mistake; the compiler is trying to tell you something. Let me guess, it is saying something like

Re: getting Win32 Messagebox to work

2018-10-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 October 2018 at 12:36:42 UTC, Mark Moorhen wrote: Can anyone help me out with this? Yeah, let me make a few general points here: * The win32.xxx packages shouldn't be necessary any longer, because they have been merged into the druntime core since those tutorials were written,

Re: getting Win32 Messagebox to work

2018-10-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 October 2018 at 15:10:14 UTC, Mark Moorhen wrote: It does compile, but does not run as expected. Any clues? You imported, but never actually called Runtime.initalize(). Just stick that at the top, first thing you do inside WinMain, and it will work. (or use main instead of WinMa

Re: struggling to link against a C global in D (win/vs2017)

2018-10-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 29 October 2018 at 00:01:21 UTC, DanielG wrote: extern DLLPROJECT_API int myIntValue; extern __gshared int myIntValue; Both are listed as extern, where is the actual variable stored? If it is in the dll, it shouldn't be extern there.

Re: struggling to link against a C global in D (win/vs2017)

2018-10-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 29 October 2018 at 00:12:43 UTC, DanielG wrote: It's defined in the .cpp file. Ah, of course, good. The other thing that might be an issue is the leading _ the compiler frequently adds. You might be able to hack it with pragma(mangle, "myIntValue") on the declaration too. idk for

Re: javascript or typescript

2018-11-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 5 November 2018 at 02:51:19 UTC, Fred wrote: i'd like to give d a try. Why do you need to convert it to javascript? D can serve up web stuff by itself too.

Re: Exception slipping through the catch block?

2018-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:08:40 UTC, helxi wrote: Shouldn't the catch block in the function catch the exception? You caught Exception, but it throws Error. They have separate inheritance trees. The common ancestor is actually Throwable, though note that there is no guarantee that

Re: How do I install a library?

2018-11-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 9 November 2018 at 01:18:51 UTC, bachmeier wrote: There's no obvious reason it can't be done that way in D It is trivial, really. Just download the files to your import path and `dmd -i`. Only hard part is the modules need to be arranged such that dmd -i will find it... and the dub

Re: Why is stdio ... stdio?

2018-11-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 10 November 2018 at 23:29:12 UTC, Jonathan M Davis wrote: The fact that they got added to ddoc just further degrades it as a proper, macro-based markup language. The backticks were added to ddoc because they enabled something that was *virtually impossible* in ddoc before - proper

Re: Why is stdio ... stdio?

2018-11-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 11 November 2018 at 03:57:22 UTC, Jonathan M Davis wrote: It may be that a feature was needed to do better character escaping Yeah, I would have preferred to just escape all of it (and axe the biggest mis"feature" ddoc has imo - embedded HTML), but it got rejected :( On the whole

Re: Function parameters UDAs

2018-11-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 14 November 2018 at 16:28:19 UTC, Radu wrote: Looks like that there is no easy way to extract a function parameters UDA list. Indeed, the only way I can find is kinda crazy: --- void foo(int f, @("test") string s) {} void main() { static if(is(typeof(foo) Params == __par

Re: opDispatch doesn't play nice with inheritance

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 17:14:21 UTC, Carl Sturtivant wrote: opDispatch is special in that it allows for functions to be added to a class or struct when undefined overtly but used elsewhere but it seems those functions sadly are final. Right, all templates are final, including opDispa

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 20:57:59 UTC, pineapple wrote: My issue is that I can't figure out how to access a function's arguments from within inline asm or how to ensure that the correct value is returned. I haven't found a single piece of documentation about this so far! It would be p

Re: what are the rules for @nogc and @safe attributes inference?

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote: what are the rules for @nogc inference? It attempts it if and only if it is a template.

Re: Where is there documentation on how to write inline asm?

2018-11-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 November 2018 at 21:07:51 UTC, pineapple wrote: Is there a way to access this pointer? It is passed as.. I think the final argument to the function. (unless it is the first, do a quick test to find out). Also, the calling convention documentation there doesn't mention anythi

Re: Not able to load classes defined in archive file in Mac OSX using Object.factory

2018-11-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 16 November 2018 at 14:24:10 UTC, Aditya wrote: ./ss/Stat.d (defines interface named 'Stat') ./ss/Min.d (defines class named 'Min' that implements Stat) Did you put a module declaration at the top of those files? Like module ss.Stat; That ought to be required; the compiler lets

Re: Not able to load classes defined in archive file in Mac OSX using Object.factory

2018-11-16 Thread Adam D. Ruppe via Digitalmars-d-learn
PS object.factory sucks and I hope it is removed some day. There's no plan to do so, but I still wouldn't actually rely on it... instead, I'd write your own factory function and registration system, so you control it and will have reliability to your specific needs. but still if the factory w

Re: subsystem:windows and writeln

2018-11-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 16 November 2018 at 17:36:01 UTC, Domain wrote: I think this is unacceptable. Why? You are asking it to write to a file that doesn't exist... you probably shouldn't be doing that...

Re: subsystem:windows and writeln

2018-11-16 Thread Adam D. Ruppe via Digitalmars-d-learn
BTW if you just want to ditch the output, you might be able to use "NUL" as the file name. I havent' tried tho.

Re: subsystem:windows and writeln

2018-11-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 16 November 2018 at 17:49:06 UTC, Domain wrote: But I cannot control the 3rd library! Hmm, I see. So one possibility would be to reopen stdout (and maybe stderr) to a different file. stdout.reopen("log.txt", "wt"); when you start your program and before you call the libr

Re: Not able to load classes defined in archive file in Mac OSX using Object.factory

2018-11-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 16 November 2018 at 14:55:52 UTC, Aditya wrote: How can one write own factory function ? Any pointers to this ? Something like Interface delegate()[string] factories; Interface create(string className) { if(className in factories) return factories[classname]; else

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 November 2018 at 20:54:24 UTC, drug wrote: https://run.dlang.io/is/IygU5D AllMembers states that struct S contains "this" member, but hasMember negates it. Is it bug or misusing? I'm not sure what it is supposed to do, but since this is kinda special - it is a keyword for the

Re: Making external types available to mixins

2018-11-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 November 2018 at 17:58:54 UTC, John Chapman wrote: Has anyone had a similar need and come up with a solution? You might be able to just pass it the Calendar type, and then fetch its parent module and get the ICalendarFactory from there (assuming they are defined in the same mo

Re: Inconsistency between `AllMembers` and `hasMember`

2018-11-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 November 2018 at 21:33:37 UTC, drug wrote: Another problem I'm trying to resolve is that if I define struct S outside of unittest or inside of unittest but using static qualifier AllMembers does not return "this". Also if struct S do not have methods AllMembers also doesn't retu

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez Hermoso wrote: What's the reasoning for allowing this? The mistake is immediately obvious when you run the program, so I just don't see it as a big deal. You lose a matter of seconds, realize the mistake, and fix it. What is your

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 20 November 2018 at 09:27:03 UTC, aberba wrote: Does D have a linter which warns about certain style of coding like this? dscanner might check it. I don't know though.

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 20 November 2018 at 13:27:28 UTC, welkam wrote: Because the more you learn about D the less you want to use classes. classes rock. You just initialize it. You're supposed to initialize *everything* anyway.

Re: D is supposed to compile fast.

2018-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 23 November 2018 at 17:21:46 UTC, H. S. Teoh wrote: Are you using template-heavy Phobos functions? Merely importing a Phobos module is liable to cost you a quarter second or more of compile time. I just got my gui lib (22,000 lines of raw source, dscanner -sloc reports 12,000) co

Re: version(StdDoc)

2018-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 23 November 2018 at 21:47:51 UTC, Tony wrote: What is the situation in which the identifier StdDoc is set? When the phobos website is being compiled, its own makefile sets that. It is basically a hack for website display.

Re: version(StdDoc)

2018-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 23 November 2018 at 23:13:04 UTC, H. S. Teoh wrote: There are a few cases where this is needed, e.g., to generate docs for Windows-specific modules, since the website script is run on Posix and the Windows APIs would not be compiled at all, leading to empty docs. Note that that is

Re: version(StdDoc)

2018-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 24 November 2018 at 01:21:25 UTC, H. S. Teoh wrote: Ddoc may have its stink points, but in this case, the stuff inside version(Windows) blocks simply isn't compiled That is why I call it "poorly designed" and a major reason why I dropped it entirely and created my own doc generato

Re: version(StdDoc)

2018-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 24 November 2018 at 02:55:04 UTC, H. S. Teoh wrote: But then that would be reinventing what Adam has already done, right? :-D Precisely, I already do all that. And people are even actually using it!

Re: version(StdDoc)

2018-11-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 24 November 2018 at 16:16:08 UTC, H. S. Teoh wrote: Actually, what would be ideal is if each platform-specific version of the symbol can have its own associated platform-specific docs, in addition to the one common across all platforms, and the doc system would automatically compil

Re: How to iterate getSymbolsByUDA

2018-11-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 November 2018 at 13:50:13 UTC, Eko Wahyudin wrote: seems my problem is i use GDC, i got this error error: basic type expected, not foreach. The common versions of gdc don't support static foreach, but plain foreach should work there the same way in this context. So just remove

Re: How to debug FinalizeError?

2018-11-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 November 2018 at 22:40:17 UTC, unDEFER wrote: Hello! After long-long time of debugging, I just have decided InvalidMemoryOperationError in my program. But now my program after few hours of testing again crashes with "Finalization error". So InvalidMemoryOperationError means a

Re: gcc 9 vs. dmd?

2018-11-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 30 November 2018 at 00:43:59 UTC, Andrew Pennebaker wrote: Given that gcc v9 should have built-in support for compiling D code, and that dmd requires gcc, will dmd continue to be supported? dmd will continue to be supported.

Re: Messing with OpenGL in D

2018-12-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 5 December 2018 at 20:36:43 UTC, Nadir Chowdhury wrote: I'm on Windows 10, so which parts would differ? Sorry, should've mentioned it in my original post. Thanks for the reply! Basically all of it lol. The principals are the same, but the specific functions are all different.

Re: public imports

2018-12-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 5 December 2018 at 21:13:29 UTC, Sjoerd Nijboer wrote: A small question. Is it intended behaviour that public imports inside function calls fail with the message "Error: found public instead of statement", or is it an underdocumented feature? Looks intended. It doesn't really ma

Re: Ambiguous virtual function

2018-12-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 December 2018 at 07:37:12 UTC, John Chapman wrote: Is the compiler giving the non-mixed-in function special treatment? Yes, this is by design: https://dlang.org/spec/template-mixin.html#mixin_scope It allows you to have multiple functions in a mixin and override them selectiv

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 December 2018 at 16:39:34 UTC, Ron Tarrant wrote: import subfolder.ModuleName; And in the module files, the first statement is: module ModuleName; That's wrong: the import name and the module name should always match, in full, including all the dot parts. So if you "import app

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 December 2018 at 17:41:47 UTC, Ron Tarrant wrote: Are you talking about a list of import statements here or is there another way/place I would list them? On the dmd command line. So say your program has a.d and b.d, you would compile with `dmd a.d b.d`. Or as you had some succes

Re: Working with ranges

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 December 2018 at 03:37:56 UTC, Murilo wrote: Hi guys, I have created an array of strings with "string[12] ps string[12] isn't a range, but string[] is. Try passing `ps[]` to the function instead of plain `ps` and see what happens.

Re: Working with ranges

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 December 2018 at 03:48:10 UTC, Murilo wrote: Try passing `ps[]` to the function instead of plain `ps` and see what happens. How do I transform an array into a range? With the slicing operator, [].

Re: Working with ranges

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 December 2018 at 04:11:03 UTC, Murilo wrote: What is the difference between declaring "int[3] a = [1,2,3];" and declaring "int[] a = [1,2,3];"? Is the first an array and the second a range? They are both arrays, just the former one has a fixed size and the latter does not. Rang

Re: Library settings, best practices?

2018-12-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 December 2018 at 16:58:24 UTC, Vladimirs Nordholm wrote: Is there a best practice to enabling specific parts of a library? For my terminal library, I put it all in a struct. Then the user gets to choose how to initialize it, and its destructor gets a chance to cleanup when done

Re: Atomic bit operations

2018-12-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 10 December 2018 at 23:20:22 UTC, Crayo List wrote: Are there atomic equivalents of bt(), btc(), bts(), btr() ... etc from core.bitop? Those are intrinsics that compile into a single cpu instruction, so they are probably already atomic...

Re: D do not know which function to use apparently

2018-12-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 11 December 2018 at 14:16:05 UTC, Narxa wrote: int var = floor(sqrt(n)) // where 'n' is a 'const int' You can just cast it to float: floor(sqrt( cast(float) n )); and it will work.

Re: How to split strings into AA using phobos

2018-12-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 11 December 2018 at 18:46:27 UTC, Andre Pany wrote: I am not 100% sure but I think query parameters names can occur multiple times in query string. Yes, that's right.

Re: Doubt about this book: The D Programming Language

2018-12-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 December 2018 at 06:08:58 UTC, Jani Hur wrote: Publish dates are 2014 and 2015. How much the language has changed/evolved since then and how much it will evolve in future ? There's a few minor changes in mine (the D Cookbook one), and a few typos in the book I didn't catch until

Re: Doubt about this book: The D Programming Language

2018-12-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 18 December 2018 at 00:36:12 UTC, Ron Tarrant wrote: Are these typos obvious, or is there an errata? They're obvious. Stuff like doubled ; at the end of lines in code samples, or curly quotes when they should be straight. (They are the result of me fighting Microsoft Word and the

Re: Checking if CTFE is used?

2018-12-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 18 December 2018 at 14:23:38 UTC, berni wrote: import std.stdio; class A { static immutable int[4] clue; static this() { if(__ctfe) assert(0, "Yep, CTFE used"); foreach (i;0..4) clue[i] = i; } } CTFE is used if and only if it MUST be used by context

Re: Weird const behavior

2018-12-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 20 December 2018 at 01:37:59 UTC, Simón Oroño wrote: The only difference (code-wise) is the `const` keyword. I've tried with both `ldc` and `dmd` with same result. Why is the output different when the variable is `const`? A const range cannot be iterated by a generic template (wit

Re: Qualified class opEquals()

2018-12-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 25 December 2018 at 14:27:39 UTC, Per Nordlöw wrote: This is a severe limitation. Are there any plans on fixing this or do I have to wait for Andrei's proposed ProtoObject? Ignore opEquals and use your own interface.

Re: Are the below statements equivalent?

2018-12-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 17:33:13 UTC, Machine Code wrote: Are the below statements equivalent? Yes, it is defined here: https://dlang.org/spec/statement.html#switch-statement (#2 in the list)

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 December 2018 at 08:53:30 UTC, Johannes Loher wrote: If this behavior is indeed intentional, it should at least be covered in the spec. I know the template part is intentional (including the identifier thing, function names are allowed to share names with global identifiers an

Re: typeof function literals which define the types of its parameters but do not give their parameters names

2018-12-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 December 2018 at 15:39:23 UTC, Steven Schveighoffer wrote: A template evaluating to a type void is how is(typeof(someTemplateDefinition)) works. Yeah, I know of that, but with __traits(isTemplate) now, I don't think there's any good reason to use the old hack detection anymore

Re: D-oriented Syntax Highlighting Plugin for WordPress?

2019-01-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 January 2019 at 20:27:44 UTC, Ron Tarrant wrote: I couldn't find a list of supported languages. Realistically, if you use Java or C++ highlighting, it will look plenty good enough for D too. So take a look down my highlight test page for my adrdox generator: http://dpldocs.i

Re: static foreach direct use of variables

2019-01-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 January 2019 at 21:14:09 UTC, Michelle Long wrote: auto foo(S s) { static foreach(k, p; [s, this]) for(int i = 0; i < p.length; i++) ... } try static foreach(...) {{ stuff }} The double {{ and double }} are intentional.

Re: 9999999999999999.0 - 9999999999999998.0

2019-01-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 6 January 2019 at 00:20:40 UTC, Samir wrote: import std.stdio: writeln; void main(){ writeln(cast(double).0-9998.0); } That's because it is done at compile time, since both are compile-time constants. The compiler will evaluate it using the maximum p

Re: D man pages

2019-01-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 6 January 2019 at 02:23:20 UTC, H. S. Teoh wrote: But something like Adam Ruppe's adrdox could possibly be the basis for translating individual module symbols into manpages perhaps? The approach I'd take is actually converting my generated html to text and just piping it through le

Re: D man pages

2019-01-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 January 2019 at 14:25:26 UTC, H. S. Teoh wrote: A text-based links browser with a focused use case sounds like a far better idea. Though programs like elinks or pinfo may have already have you beat on this front. :-D elinks does an ok job on dpldocs (of course, I partially designe

Re: signed nibble

2019-01-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 January 2019 at 18:42:13 UTC, Patrick Schluter wrote: byte b = nibble | ((nibble & 0x40)?0xF0:0); don't you mean & 0x80 ?

Re: Reversing a string

2019-01-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 January 2019 at 13:51:04 UTC, JN wrote: I guess something like iterReverse, reverseIter, backIterator would be too simple... or foreach_reverse, which never actually was removed! lol

Re: Generating API documention

2019-01-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 January 2019 at 07:04:52 UTC, George wrote: What do people use to generate nice looking and simple html documentation for their projects? If you like my style and syntax

Re: Print a copyright symbol

2019-01-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 January 2019 at 16:48:40 UTC, Head Scratcher wrote: How would I use writeln to print a copyright symbol to the console? I have tried using the unicode code \u00A9, as well as embedding the symbol directly in the string, but I just get garbage when I run it. You need to be using

<    5   6   7   8   9   10   11   12   13   14   >