Re: dub.json dependencies per configuration?
On Wednesday, 11 February 2015 at 01:06:02 UTC, Mike Parker wrote: On 2/11/2015 8:38 AM, Arjan wrote: Snippet from: https://github.com/buggins/ddbc/blob/master/dub.json#L7 ddbc has a "dependencies" on "mysql-native": ">=0.0.12". But this is only true for "configurations": "MySQL". Is it allowed to put the dependency within the configuration section for "MySQL?. Yes. I moved the "dependencies" into the configuration of "MySQL", but no dice. It is accepted by dub but does not make a difference when selecting an other configuration. e.g. "dub build -f -c SQLite -a x86" still fetches and builds the "mysql-native". Is this behavior of dub expected or a bug?
Re: Why is one d file compiled into two files object file & executable.
On Wednesday, 11 February 2015 at 05:08:16 UTC, Venkat Akkineni wrote: I am coming from Java. What is the purpose of an object file & why is it generated at compile time in addition to an executable. I know C generates an object file too, but I don't know what the use is. Java uses a similar process: it has to generate .class files before they can be packed into a .jar file.
Re: Why is one d file compiled into two files object file & executable.
On Wednesday, 11 February 2015 at 05:08:16 UTC, Venkat Akkineni wrote: Hi I am coming from Java. What is the purpose of an object file & why is it generated at compile time in addition to an executable. I know C generates an object file too, but I don't know what the use is. Hi Venkat, The object files are kind of an intermediate format produced by the compiler, to be used by the linker in generating the executable. Please point me to any detailed documentation u may have regarding object files. If you wish to learn more the following Wikipedia article is a reasonable starting point. http://en.wikipedia.org/wiki/Object_file Also does D have any facilities for dynamic code generation & compilation ? Yes, it does. D has good support for meta-programming, look at http://ddili.org/ders/d.en/ under the template and mixin sections, and also http://qznc.github.io/d-tut/meta.html
Re: primitive type variables not nullable ?
Thanks Gentlemen. That helped. On Monday, 9 February 2015 at 00:00:00 UTC, bearophile wrote: Tobias Pankrath: Check for null with (x is null) not via printing to stdout. In most cases instead of checking dynamic arrays for null, it's better to use std.array.empty. Bye, bearophile
Why is one d file compiled into two files object file & executable.
Hi I am coming from Java. What is the purpose of an object file & why is it generated at compile time in addition to an executable. I know C generates an object file too, but I don't know what the use is. Please point me to any detailed documentation u may have regarding object files. Also does D have any facilities for dynamic code generation & compilation ? Thankyou Sincerely Venkat
Re: Intended to be able to RefCount an interface?
On Tuesday, 10 February 2015 at 06:26:39 UTC, weaselcat wrote: Is there currently an enhancement request open for this on the bug tracker? I cannot find anything. I couldn't find it either, so I filed it: https://issues.dlang.org/show_bug.cgi?id=14168
Re: To write such an expressive code D
On 2015-02-11 at 01:56, bearophile wrote: Alternative solution closer to the F# code: import std.stdio, std.algorithm, std.typecons; int f(T)(T t) if (isTuple!T) { return t.predSwitch( tuple(0, 0, 0), 0, tuple(0, 1, 1), 0, tuple(1, 0, 1), 0, tuple(1, 1, 0), 0, /*else*/ 1); } void main() { foreach (immutable a; 0 .. 2) foreach (immutable b; 0 .. 2) foreach (immutable c; 0 .. 2) writefln("%d xor %d xor %d = %d", a, b, c, tuple(a, b, c).f); } Why bend over and try to make it F#? Screw the F# guy. He was cheating with a switch, so why can't we cheat? foreach(i;0..8)writefln("%d xor %d xor %d = %s",!!(i&4),!!(i&2),!!(i&1),"01101001"[i]); Assimilate this! Oh wait, you needed a function. OK, here's a function (and just replace "01101001"[i] with xxor(i&4,i&2,i&1)): int xxor(int a, int b, int c) {return (a&&b&&c)||(!a&&!b&&c)||(!a&&b&&!c)||(a&&!b&&!c);} If it makes him dislike D even more, great! Mission accomplished. :)
Re: To write such an expressive code D
On Wednesday, 11 February 2015 at 00:56:03 UTC, bearophile wrote: Dennis Ritchie: Output: 0 xor 0 xor 0 = 0 0 xor 0 xor 1 = 1 0 xor 1 xor 0 = 1 0 xor 1 xor 1 = 0 1 xor 0 xor 0 = 1 1 xor 0 xor 1 = 0 1 xor 1 xor 0 = 0 1 xor 1 xor 1 = 1 This man again took advantage of the fact that in D there is no such operation -> (analog switch). A natural solution in D: void main() { import std.stdio; foreach (immutable a; 0 .. 2) foreach (immutable b; 0 .. 2) foreach (immutable c; 0 .. 2) writefln("%d xor %d xor %d = %d", a, b, c, (a + b + c) % 2); } Alternative solution closer to the F# code: import std.stdio, std.algorithm, std.typecons; int f(T)(T t) if (isTuple!T) { return t.predSwitch( tuple(0, 0, 0), 0, tuple(0, 1, 1), 0, tuple(1, 0, 1), 0, tuple(1, 1, 0), 0, /*else*/ 1); } void main() { foreach (immutable a; 0 .. 2) foreach (immutable b; 0 .. 2) foreach (immutable c; 0 .. 2) writefln("%d xor %d xor %d = %d", a, b, c, tuple(a, b, c).f); } Bye, bearophile Thanks.
Re: dub.json dependencies per configuration?
On 2/11/2015 8:38 AM, Arjan wrote: Snippet from: https://github.com/buggins/ddbc/blob/master/dub.json#L7 ddbc has a "dependencies" on "mysql-native": ">=0.0.12". But this is only true for "configurations": "MySQL". Is it allowed to put the dependency within the configuration section for "MySQL?. Yes.
Re: To write such an expressive code D
Dennis Ritchie: Output: 0 xor 0 xor 0 = 0 0 xor 0 xor 1 = 1 0 xor 1 xor 0 = 1 0 xor 1 xor 1 = 0 1 xor 0 xor 0 = 1 1 xor 0 xor 1 = 0 1 xor 1 xor 0 = 0 1 xor 1 xor 1 = 1 This man again took advantage of the fact that in D there is no such operation -> (analog switch). A natural solution in D: void main() { import std.stdio; foreach (immutable a; 0 .. 2) foreach (immutable b; 0 .. 2) foreach (immutable c; 0 .. 2) writefln("%d xor %d xor %d = %d", a, b, c, (a + b + c) % 2); } Alternative solution closer to the F# code: import std.stdio, std.algorithm, std.typecons; int f(T)(T t) if (isTuple!T) { return t.predSwitch( tuple(0, 0, 0), 0, tuple(0, 1, 1), 0, tuple(1, 0, 1), 0, tuple(1, 1, 0), 0, /*else*/ 1); } void main() { foreach (immutable a; 0 .. 2) foreach (immutable b; 0 .. 2) foreach (immutable c; 0 .. 2) writefln("%d xor %d xor %d = %d", a, b, c, tuple(a, b, c).f); } Bye, bearophile
Re: Ncurses deprecated "~master" issue
On Tuesday, 10 February 2015 at 21:14:36 UTC, H. S. Teoh wrote: Judging by the name of the object file (test.o) and the name of the code section (.text), I'd say this is definitely Posix. :-) So the question is why that ctor isn't defined in spite of it being Posix. T Heh, you are right. I only use D on Windows and since I mostly use VisualD I don't remember what the error messages look like.
Re: To write such an expressive code D
F#: let f = function | 0 , 0 , 0 -> 0 | 0 , 1 , 1 -> 0 | 1 , 0 , 1 -> 0 | 1 , 1 , 0 -> 0 | _ -> 1 for a in 0..1 do for b in 0..1 do for c in 0..1 do printfn "%i xor %i xor %i = %i" a b c (f (a, b, c)) Output: 0 xor 0 xor 0 = 0 0 xor 0 xor 1 = 1 0 xor 1 xor 0 = 1 0 xor 1 xor 1 = 0 1 xor 0 xor 0 = 1 1 xor 0 xor 1 = 0 1 xor 1 xor 0 = 0 1 xor 1 xor 1 = 1 This man again took advantage of the fact that in D there is no such operation -> (analog switch).
Re: Ncurses deprecated "~master" issue
On Tuesday, 10 February 2015 at 21:11:14 UTC, Paul wrote: Yes, I noted the default values, even if I don't understand what they do at present(!). They allow overriding of the input/output files. fdIn normally refers to standard input, fdOut refers to standard output, and the getSizeOverride lets you provide a custom function instead of the default, which is to ask the operating system for the size of the terminal with ioctl. I added those options to support my detachable.d program, which is like GNU Screen - it can detach from the terminal and keep running. Instead of talking straight to the actual terminal files, it talks through a socket to a helper program which lets it be reattached on a new terminal.
dub.json dependencies per configuration?
Snippet from: https://github.com/buggins/ddbc/blob/master/dub.json#L7 ddbc has a "dependencies" on "mysql-native": ">=0.0.12". But this is only true for "configurations": "MySQL". Is it allowed to put the dependency within the configuration section for "MySQL?. "dependencies": { "mysql-native": ">=0.0.12" }, "targetPath": "lib", "targetType": "staticLibrary", "configurations": [ { "name": "full", "versions": ["USE_MYSQL", "USE_SQLITE", "USE_PGSQL"], "libs-posix": ["sqlite3", "pq"], "libs-windows": ["sqlite3", "libpq"], "copyFiles-windows-x86": [ "libs/win32/sqlite3.dll", "libs/win32/libpq.dll", "libs/win32/intl.dll" ], "sourceFiles-windows-x86" : [ "libs/win32/sqlite3.lib", "libs/win32/libpq.lib" ] }, { "name": "MySQL", "versions": ["USE_MYSQL"] }, { "name": "SQLite", "versions": ["USE_SQLITE"], "libs-posix": ["sqlite3"], "libs-windows": ["sqlite3"], "copyFiles-windows-x86": [ "libs/win32/sqlite3.dll" ], "sourceFiles-windows-x86" : [ "libs/win32/sqlite3.lib" ] }, { "name": "PGSQL", "versions": ["USE_PGSQL"], "libs-posix": ["pq"], "libs-windows": ["libpq"], "copyFiles-windows-x86": [ "libs/win32/libpq.dll", "libs/win32/intl.dll" ], "sourceFiles-windows-x86" : [ "libs/win32/libpq.lib" ] } ]
Re: Ncurses deprecated "~master" issue
On Tuesday, 10 February 2015 at 21:05:08 UTC, Meta wrote: On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: On Tuesday, 10 February 2015 at 19:49:26 UTC, ketmar wrote: On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: I can't answer your question, but if you're just prototyping you could use Adam Ruppe's terminal.d until you get ncurses working. https://github.com/adamdruppe/arsd/blob/master/terminal.d and i daresay that with 'terminal.d' there is no need in ncurses at all (except if someone needs ncurses panels, but i can't imagine why). Thanks both for the replies. Terminal.d looks as though it will do what I want but I'm familiar with using ncurses and could do without learning to use yet another api at the minute. Nevertheless, I had a quick look, but trying to create an instance of the Terminal struct like so: Terminal myTerm = Terminal(ConsoleOutputType.cellular, 0, 1, null); (which I think is the corrct way to do it!) gives me this error: test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' test.d:(.text._Dmain+0x3c): undefined reference to `_D8terminal8Terminal6__ctorMFNcE8terminal17ConsoleOutputTypeiiDFZAiZS8terminal8Terminal' test.d:(.text._Dmain+0x6a): undefined reference to `_D8terminal8Terminal6__dtorMFZv' collect2: error: ld returned 1 exit status --- errorlevel 1 I have no idea how to fix that. Any suggestions please? Are you on Linux or Windows? That constructor is only defined on Posix-based systems. Sorry I missed your post, I'm on Linux Mint 17.
Re: Ncurses deprecated "~master" issue
On Tuesday, 10 February 2015 at 20:57:43 UTC, Adam D. Ruppe wrote: On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' If you see 'undefined reference' it means some library wasn't passed to the compiler. Easiest fix is usually to add the .d files to the command line so: dmd yourfile.d terminal.d with both passed together should build successfully. BTW only the first argument to Terminal() is required, the others have sane defaults. Thank you Adam. Yes, I noted the default values, even if I don't understand what they do at present(!). I'm pretty sure I tried to pass both files to the compiler at one point but I had illegal characters in my source filename (test-terminal.d) which sent me off on another track! No matter, it works as expected now, so I can take it for a spin.
Re: Ncurses deprecated "~master" issue
On Tue, Feb 10, 2015 at 09:05:06PM +, Meta via Digitalmars-d-learn wrote: > On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: [...] > >test.o: In function `_Dmain': > >test.d:(.text._Dmain+0x13): undefined reference to > >`_D8terminal8Terminal6__initZ' > >test.d:(.text._Dmain+0x3c): undefined reference to > >`_D8terminal8Terminal6__ctorMFNcE8terminal17ConsoleOutputTypeiiDFZAiZS8terminal8Terminal' > >test.d:(.text._Dmain+0x6a): undefined reference to > >`_D8terminal8Terminal6__dtorMFZv' > >collect2: error: ld returned 1 exit status > >--- errorlevel 1 > > > >I have no idea how to fix that. Any suggestions please? > > Are you on Linux or Windows? That constructor is only defined on > Posix-based systems. Judging by the name of the object file (test.o) and the name of the code section (.text), I'd say this is definitely Posix. :-) So the question is why that ctor isn't defined in spite of it being Posix. T -- Some ideas are so stupid that only intellectuals could believe them. -- George Orwell
Re: Ncurses deprecated "~master" issue
On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: On Tuesday, 10 February 2015 at 19:49:26 UTC, ketmar wrote: On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: I can't answer your question, but if you're just prototyping you could use Adam Ruppe's terminal.d until you get ncurses working. https://github.com/adamdruppe/arsd/blob/master/terminal.d and i daresay that with 'terminal.d' there is no need in ncurses at all (except if someone needs ncurses panels, but i can't imagine why). Thanks both for the replies. Terminal.d looks as though it will do what I want but I'm familiar with using ncurses and could do without learning to use yet another api at the minute. Nevertheless, I had a quick look, but trying to create an instance of the Terminal struct like so: Terminal myTerm = Terminal(ConsoleOutputType.cellular, 0, 1, null); (which I think is the corrct way to do it!) gives me this error: test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' test.d:(.text._Dmain+0x3c): undefined reference to `_D8terminal8Terminal6__ctorMFNcE8terminal17ConsoleOutputTypeiiDFZAiZS8terminal8Terminal' test.d:(.text._Dmain+0x6a): undefined reference to `_D8terminal8Terminal6__dtorMFZv' collect2: error: ld returned 1 exit status --- errorlevel 1 I have no idea how to fix that. Any suggestions please? Are you on Linux or Windows? That constructor is only defined on Posix-based systems.
Re: Ncurses deprecated "~master" issue
On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' If you see 'undefined reference' it means some library wasn't passed to the compiler. Easiest fix is usually to add the .d files to the command line so: dmd yourfile.d terminal.d with both passed together should build successfully. BTW only the first argument to Terminal() is required, the others have sane defaults.
Re: Ncurses deprecated "~master" issue
On Tuesday, 10 February 2015 at 19:49:26 UTC, ketmar wrote: On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: I can't answer your question, but if you're just prototyping you could use Adam Ruppe's terminal.d until you get ncurses working. https://github.com/adamdruppe/arsd/blob/master/terminal.d and i daresay that with 'terminal.d' there is no need in ncurses at all (except if someone needs ncurses panels, but i can't imagine why). Thanks both for the replies. Terminal.d looks as though it will do what I want but I'm familiar with using ncurses and could do without learning to use yet another api at the minute. Nevertheless, I had a quick look, but trying to create an instance of the Terminal struct like so: Terminal myTerm = Terminal(ConsoleOutputType.cellular, 0, 1, null); (which I think is the corrct way to do it!) gives me this error: test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' test.d:(.text._Dmain+0x3c): undefined reference to `_D8terminal8Terminal6__ctorMFNcE8terminal17ConsoleOutputTypeiiDFZAiZS8terminal8Terminal' test.d:(.text._Dmain+0x6a): undefined reference to `_D8terminal8Terminal6__dtorMFZv' collect2: error: ld returned 1 exit status --- errorlevel 1 I have no idea how to fix that. Any suggestions please?
Re: Ncurses deprecated "~master" issue
On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: > I can't answer your question, but if you're just prototyping you could > use Adam Ruppe's terminal.d until you get ncurses working. > https://github.com/adamdruppe/arsd/blob/master/terminal.d and i daresay that with 'terminal.d' there is no need in ncurses at all (except if someone needs ncurses panels, but i can't imagine why). signature.asc Description: PGP signature
Re: Ncurses deprecated "~master" issue
On Tuesday, 10 February 2015 at 13:18:34 UTC, Paul wrote: On Wednesday, 3 December 2014 at 19:37:03 UTC, Paul wrote: On Wednesday, 3 December 2014 at 17:37:18 UTC, Matt Soucy wrote: On 12/03/2014 07:07 AM, Paul wrote: Sorry if this is a little off-topic, I posted this in the Dub forum on 23/11/14 but have had no reply yet: --- I read that the use of a branch spec like "~master" in dub.json is deprecated. I also read that it could be overriden on a per-project basis by editing the project's dub.selections.json file but I can't find any information about what is actually required in this file and whether any corresponding changes need to be made to dub.json. I'm trying to use 'ncurses' which doesn't have a version number, only "~master". --- Also, does anyone know how 'beta' the ncurses module actually is, is anyone using it? Cheers Paul So, as far as I know there isn't any plan for versioning that specific library. I've used it, however, and it's pretty usable (as much as ncurses goes, at any rate). So do I manually add those source files to my program (assuming the ncurses libs are installed) if compiling with dmd rather than using dub? Bump! I need to use ncurses for some quick prototyping now but I still can't get it to work. Can someone please spell out the steps I need to take to get this going? I'm using dmd on a linux mint box and have ncurses (and dev package) installed. What do I need to install and import exactly if I don't utilise Dub? TIA Paul I can't answer your question, but if you're just prototyping you could use Adam Ruppe's terminal.d until you get ncurses working. https://github.com/adamdruppe/arsd/blob/master/terminal.d
Re: Classes and @disable this()
On 2/10/15 12:15 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, February 10, 2015 11:16:21 via Digitalmars-d-learn wrote: On Monday, 9 February 2015 at 20:15:28 UTC, Jonathan M Davis Why would it we even allow it? What benefit is there? It's meaningless. @disable this(); is for disabling the init property on structs. Classes themselves have no init values - and their references have null as their init value. No, `@disable this()` does _not_ disable the init property on structs. It disables default, i.e. argument-less construction. Which is analogous to `new MyClass()`. It makes perfect sense to disable argument-less construction in classes, just like with structs. (They are of course different, in that struct default constructors don't "do" anything, but that's not relevant here.) Well, then that's a change. It used to be that @disable this() completely disabled the init property. So, I guess now it just disables its implicit use, which probably screws up its use for stuff like a NonNullable (which is why it exists in the first place), but having types without an init property definitely would make things nasty with generic code (which is where we sat for a while, I believe). No, it's not a change. You could always do: S s = S.init; What the feature disabled is this: S s; -Steve
Re: Compilation with dub + dmd: out of memory
On Tuesday, 10 February 2015 at 12:18:15 UTC, Vlasov Roman wrote: On Tuesday, 10 February 2015 at 11:55:43 UTC, Daniel Kozák wrote: V Tue, 10 Feb 2015 11:44:09 + Vlasov Roman via Digitalmars-d-learn napsáno: On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: > Vlasov Roman: > >> I have the quite computer with 2 GB RAM. At compilation >> with dub and dmd of small project this pair eating about >> 1.4~1.5 GB RAM. I solve this probleb by connecting swap >> partition, but it calls some freezes + it take ~10% of >> swap, and after compilation swap not released. At >> switching off swap as result we get ~200 MB of "dead data" >> in RAM, which can be released by rebooting. How i can >> resolve it? > > Look for CTFE code, perhaps some of it is excessive. You > can convert some of it to run-time in a module-level static > this(). > > Bye, > bearophile I think you don't understand me. 1.4~1.5 GB taked by compilator at compilation my project in 100 string of code in 3 modules. Still it could be code dependent, can you share your code anywhere? https://bitbucket.org/VlasovRoman/ogl/overview a bit offtopic from your thread but maybe you are interested ... at vienna university of technology i attended a similar software rendering course, some resources are publicly available (and in english) https://lva.cg.tuwien.ac.at/ecg/wiki/doku.php some impressions from previous years entries: https://lva.cg.tuwien.ac.at/ecg/wiki/doku.php?id=students:ws2013:hall_of_fame
Re: Classes and @disable this()
On Tuesday, February 10, 2015 11:16:21 via Digitalmars-d-learn wrote: > On Monday, 9 February 2015 at 20:15:28 UTC, Jonathan M Davis > > Why would it we even allow it? What benefit is there? It's > > meaningless. > > @disable this(); is for disabling the init property on structs. > > Classes > > themselves have no init values - and their references have null > > as their > > init value. > > No, `@disable this()` does _not_ disable the init property on > structs. It disables default, i.e. argument-less construction. > Which is analogous to `new MyClass()`. It makes perfect sense to > disable argument-less construction in classes, just like with > structs. (They are of course different, in that struct default > constructors don't "do" anything, but that's not relevant here.) Well, then that's a change. It used to be that @disable this() completely disabled the init property. So, I guess now it just disables its implicit use, which probably screws up its use for stuff like a NonNullable (which is why it exists in the first place), but having types without an init property definitely would make things nasty with generic code (which is where we sat for a while, I believe). - Jonathan M Davis
Re: Compilation with dub + dmd: out of memory
On Tue, 10 Feb 2015 13:03:14 +, Vlasov Roman wrote: > Whether correctly I understand that the problem is that my dependences > have other dependences which are compiled with my project? dub tries to build the libraries your project depends on, and some of that libraries are very big. but once that libraries are built, you may be able to build your project in one go. > Yes, i very surpriced, because i use only 1-2 "shared" modules. > So, i can copy this modules just in my project, but in big projects this > problem can be very serious. did you tried the proposed "--build-mode=singleFile" mode? signature.asc Description: PGP signature
Re: Ncurses deprecated "~master" issue
On Wednesday, 3 December 2014 at 19:37:03 UTC, Paul wrote: On Wednesday, 3 December 2014 at 17:37:18 UTC, Matt Soucy wrote: On 12/03/2014 07:07 AM, Paul wrote: Sorry if this is a little off-topic, I posted this in the Dub forum on 23/11/14 but have had no reply yet: --- I read that the use of a branch spec like "~master" in dub.json is deprecated. I also read that it could be overriden on a per-project basis by editing the project's dub.selections.json file but I can't find any information about what is actually required in this file and whether any corresponding changes need to be made to dub.json. I'm trying to use 'ncurses' which doesn't have a version number, only "~master". --- Also, does anyone know how 'beta' the ncurses module actually is, is anyone using it? Cheers Paul So, as far as I know there isn't any plan for versioning that specific library. I've used it, however, and it's pretty usable (as much as ncurses goes, at any rate). So do I manually add those source files to my program (assuming the ncurses libs are installed) if compiling with dmd rather than using dub? Bump! I need to use ncurses for some quick prototyping now but I still can't get it to work. Can someone please spell out the steps I need to take to get this going? I'm using dmd on a linux mint box and have ncurses (and dev package) installed. What do I need to install and import exactly if I don't utilise Dub? TIA Paul
Re: Compilation with dub + dmd: out of memory
On Tuesday, 10 February 2015 at 12:42:07 UTC, ketmar wrote: On Tue, 10 Feb 2015 11:44:09 +, Vlasov Roman wrote: On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: Vlasov Roman: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by connecting swap partition, but it calls some freezes + it take ~10% of swap, and after compilation swap not released. At switching off swap as result we get ~200 MB of "dead data" in RAM, which can be released by rebooting. How i can resolve it? Look for CTFE code, perhaps some of it is excessive. You can convert some of it to run-time in a module-level static this(). Bye, bearophile I think you don't understand me. 1.4~1.5 GB taked by compilator at compilation my project in 100 string of code in 3 modules. "fileVersion": 1, "versions": { "dunit": "1.0.10", "descore": "1.2.0", "derelict-ft": "1.0.2", "derelict-util": "1.9.1", "tga": "0.1.0", "des": "1.3.3", "derelict-sdl2": "1.9.1", "derelict-gl3": "1.0.12" } wow-wow, do you REALLY expect all that to compile with few megs of RAM? run "dub -v" and see the command lines. you'll be very surprised. Whether correctly I understand that the problem is that my dependences have other dependences which are compiled with my project? Yes, i very surpriced, because i use only 1-2 "shared" modules. So, i can copy this modules just in my project, but in big projects this problem can be very serious.
Re: Compilation with dub + dmd: out of memory
On Tue, 10 Feb 2015 11:44:09 +, Vlasov Roman wrote: > On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: >> Vlasov Roman: >> >>> I have the quite computer with 2 GB RAM. At compilation with dub and >>> dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve >>> this probleb by connecting swap partition, but it calls some freezes + >>> it take ~10% of swap, and after compilation swap not released. At >>> switching off swap as result we get ~200 MB of "dead data" in RAM, >>> which can be released by rebooting. How i can resolve it? >> >> Look for CTFE code, perhaps some of it is excessive. You can convert >> some of it to run-time in a module-level static this(). >> >> Bye, >> bearophile > > I think you don't understand me. 1.4~1.5 GB taked by compilator at > compilation my project in 100 string of code in 3 modules. "fileVersion": 1, "versions": { "dunit": "1.0.10", "descore": "1.2.0", "derelict-ft": "1.0.2", "derelict-util": "1.9.1", "tga": "0.1.0", "des": "1.3.3", "derelict-sdl2": "1.9.1", "derelict-gl3": "1.0.12" } wow-wow, do you REALLY expect all that to compile with few megs of RAM? run "dub -v" and see the command lines. you'll be very surprised. signature.asc Description: PGP signature
Re: Compilation with dub + dmd: out of memory
On Tuesday, 10 February 2015 at 11:55:43 UTC, Daniel Kozák wrote: V Tue, 10 Feb 2015 11:44:09 + Vlasov Roman via Digitalmars-d-learn napsáno: On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: > Vlasov Roman: > >> I have the quite computer with 2 GB RAM. At compilation >> with dub and dmd of small project this pair eating about >> 1.4~1.5 GB RAM. I solve this probleb by connecting swap >> partition, but it calls some freezes + it take ~10% of >> swap, and after compilation swap not released. At switching >> off swap as result we get ~200 MB of "dead data" in RAM, >> which can be released by rebooting. How i can resolve it? > > Look for CTFE code, perhaps some of it is excessive. You can > convert some of it to run-time in a module-level static > this(). > > Bye, > bearophile I think you don't understand me. 1.4~1.5 GB taked by compilator at compilation my project in 100 string of code in 3 modules. Still it could be code dependent, can you share your code anywhere? https://bitbucket.org/VlasovRoman/ogl/overview
Re: Compilation with dub + dmd: out of memory
V Tue, 10 Feb 2015 11:44:09 + Vlasov Roman via Digitalmars-d-learn napsáno: > On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: > > Vlasov Roman: > > > >> I have the quite computer with 2 GB RAM. At compilation with > >> dub and dmd of small project this pair eating about 1.4~1.5 GB > >> RAM. I solve this probleb by connecting swap partition, but it > >> calls some freezes + it take ~10% of swap, and after > >> compilation swap not released. At switching off swap as result > >> we get ~200 MB of "dead data" in RAM, which can be released by > >> rebooting. How i can resolve it? > > > > Look for CTFE code, perhaps some of it is excessive. You can > > convert some of it to run-time in a module-level static this(). > > > > Bye, > > bearophile > > I think you don't understand me. 1.4~1.5 GB taked by compilator > at compilation my project in 100 string of code in 3 modules. > Still it could be code dependent, can you share your code anywhere?
Re: Compilation with dub + dmd: out of memory
On Tuesday, 10 February 2015 at 11:24:21 UTC, Vlasov Roman wrote: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. DMD 2.067 will have memory (an in turn speed) optimizations in CTFE.
Re: Compilation with dub + dmd: out of memory
On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: Vlasov Roman: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by connecting swap partition, but it calls some freezes + it take ~10% of swap, and after compilation swap not released. At switching off swap as result we get ~200 MB of "dead data" in RAM, which can be released by rebooting. How i can resolve it? Look for CTFE code, perhaps some of it is excessive. You can convert some of it to run-time in a module-level static this(). Bye, bearophile I think you don't understand me. 1.4~1.5 GB taked by compilator at compilation my project in 100 string of code in 3 modules.
Re: Compilation with dub + dmd: out of memory
On Tuesday, 10 February 2015 at 11:24:21 UTC, Vlasov Roman wrote: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by connecting swap partition, but it calls some freezes + it take ~10% of swap, and after compilation swap not released. At switching off swap as result we get ~200 MB of "dead data" in RAM, which can be released by rebooting. How i can resolve it? First, if the program terminated, there is no dead data. Some might be shown as used with utilities as top, but running 'free' will probably show that your data is still "buffered", but available for other programs to use. You can run this command to see the effect of dropping cache: free && sync && echo 3 > /proc/sys/vm/drop_caches && free Back to dub... DMD way of managing memory is fast, at the expense of memory. I could not really enjoy fast compile time on my 4 GB machine either, everything changed when I switched to 8 GB. There is an option in dub to compile every object file separately, it's '--build-mode=singleFile'. However, it has no tracking of updated files (as make as), so it rebuild everything, everytime. It makes the whole process slower, but you can use it if you run out of memory (I compiled Vibe.d on a 512 MB machine few months ago).
Re: To write such an expressive code D
On Tue, 10 Feb 2015 11:33:54 +, bearophile wrote: > Dennis Ritchie: > >> Please help. > > This starts to look like homework :-) it's much worse: meaningless pseudocomparison of different languages for nothing. signature.asc Description: PGP signature
Re: To write such an expressive code D
On Tuesday, 10 February 2015 at 11:41:20 UTC, ketmar wrote: On Tue, 10 Feb 2015 11:33:54 +, bearophile wrote: Dennis Ritchie: Please help. This starts to look like homework :-) it's much worse: meaningless pseudocomparison of different languages for nothing. This task can be solved for D?
Re: To write such an expressive code D
On Tuesday, 10 February 2015 at 11:33:54 UTC, bearophile wrote: Dennis Ritchie: Please help. This starts to look like homework :-) Bye, bearophile This is not homework - this is a war of code on C#/F# and D. I've been programming in D, my opponent on F#/C#.
Re: To write such an expressive code D
Dennis Ritchie: Please help. This starts to look like homework :-) Bye, bearophile
Re: Compilation with dub + dmd: out of memory
Vlasov Roman: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by connecting swap partition, but it calls some freezes + it take ~10% of swap, and after compilation swap not released. At switching off swap as result we get ~200 MB of "dead data" in RAM, which can be released by rebooting. How i can resolve it? Look for CTFE code, perhaps some of it is excessive. You can convert some of it to run-time in a module-level static this(). Bye, bearophile
Re: To write such an expressive code D
Please help. import std.stdio; import std.stdio; void main() { /* return (a xor b xor c) */ int nobitxor(int a, int b, int c) { return (a + b + c == 2 || a + b + c == 0) ? 0 : 1; } int a, b, c; a = b = c = 0; foreach (i; 0 .. 8) { if (i > 3) a = 1; if (i == 2 || i == 3 || i == 6 || i == 7) b = 1; if (i % 2) c = 1; writeln(a, b, c, ' ', nobitxor(a, b, c)); a = b = c = 0; } } Output: 000 0 001 1 010 1 011 0 100 1 101 0 110 0 111 1 You need to function nobitxor(int a, int b, int c) not used bitwise/logical and mathematical operations.
Compilation with dub + dmd: out of memory
I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by connecting swap partition, but it calls some freezes + it take ~10% of swap, and after compilation swap not released. At switching off swap as result we get ~200 MB of "dead data" in RAM, which can be released by rebooting. How i can resolve it?
Re: Classes and @disable this()
On Monday, 9 February 2015 at 20:15:28 UTC, Jonathan M Davis wrote: On Monday, February 09, 2015 13:29:22 Steven Schveighoffer via Digitalmars-d-learn wrote: On 2/8/15 2:57 PM, Jonathan M Davis via Digitalmars-d-learn wrote: > On Sunday, February 08, 2015 17:51:09 bearophile via > Digitalmars-d-learn wrote: >> fra: >> >>> However making it a compiler error would be far, far better >> >> I think this can be filed in Bugzilla as diagnostic >> enhancement: >> >> >> class Foo { >> @disable this(); >> this(int i) {} >> } >> void main() {} > > The compiler should probably just give you an error telling > you that > disabling the default constructor on classes is illegal. And > since no > default constructor is automatically declared if you declare > another > constructor, there isn't even any point in disabling the > default constructor > (which is probably why no one has been complaining about > this). @disable > this() only makes sense on structs. Why? I think it's perfectly acceptable. What should be illegal is if you extend Foo and don't @disable this on the derivative. Why would it we even allow it? What benefit is there? It's meaningless. @disable this(); is for disabling the init property on structs. Classes themselves have no init values - and their references have null as their init value. No, `@disable this()` does _not_ disable the init property on structs. It disables default, i.e. argument-less construction. Which is analogous to `new MyClass()`. It makes perfect sense to disable argument-less construction in classes, just like with structs. (They are of course different, in that struct default constructors don't "do" anything, but that's not relevant here.) The default constructor already follows sensible rules where it's not generated if another constructor is declared, and derived classes have to call a base class constructor if the base class doesn't have a default constructor. Therefore `@disable this()` is redundant in that case, but still meaningful.
Re: How to Write Raw Bytes to Disk
On Tuesday, 10 February 2015 at 11:03:06 UTC, Per Nordlöw wrote: How do I write a byte[] in raw (unformatted) format to disk? File("f.raw", "wb").write(x) doesn't seem to do it. Why isn't the "wb" interpreted as raw bytes? Oops, I just discovered File("f.raw", "wb").rawWrite(x) .
How to Write Raw Bytes to Disk
How do I write a byte[] in raw (unformatted) format to disk? File("f.raw", "wb").write(x) doesn't seem to do it. Why isn't the "wb" interpreted as raw bytes?
Re: "cannot deduce function from argument types" issue.
bearophile wrote: > ted: > >> ... where you say 'More DRY' above, are you referring to > > I was referring to both, but mostly to the typeof. It's more DRY > (http://en.wikipedia.org/wiki/Don%27t_repeat_yourself ). You are > stating only once the type of the return variable. This is less > bug-prone. > > Bye, > bearophile Ha ! ..more stuff to learn! many thanks... regards, ted
Re: To write such an expressive code D
On Tue, 10 Feb 2015 08:40:36 +, Dennis Ritchie wrote: > On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote: >> Why is that? > > ÐоÑÐ¾Ð¼Ñ ÑÑо Ñ ÑпоÑил Ñ Ð¾Ð´Ð½Ð¸Ð¼ ÑпÑÑÑÑм > Ñеловеком, коÑоÑÐ¾Ð¼Ñ Ð½Ðµ нÑавиÑÑÑ D, > на ÑÑом ÑоÑÑме: > http://www.cyberforum.ru/holywars/thread1367892-page13.html Ðн пÑоÑил > Ð¼ÐµÐ½Ñ Ð½Ð°Ð¿Ð¸ÑаÑÑ ÑакÑÑ Ð¿ÑогÑÐ°Ð¼Ð¼Ñ Ñ > иÑполÑзованием ÑолÑко возможноÑÑей ÑзÑка > и ÑÑнкÑии sin(). > > Because I was arguing with one quiet a stubborn person who does not like > D, on this forum: > http://www.cyberforum.ru/holywars/thread1367892-page13.html He asked me > to write such a program using only the language features and functions > sin(). 'cause he is a dumb asshead, that's it. signature.asc Description: PGP signature
Re: "cannot deduce function from argument types" issue.
ted: ... where you say 'More DRY' above, are you referring to I was referring to both, but mostly to the typeof. It's more DRY (http://en.wikipedia.org/wiki/Don%27t_repeat_yourself ). You are stating only once the type of the return variable. This is less bug-prone. Bye, bearophile
Re: "cannot deduce function from argument types" issue.
On 02/10/2015 01:08 AM, bearophile wrote: > // Not OK > void bar(size_t N)(int[N] a, int[N ^^ 2] b) {} > So perhaps my suggestion to file an enhancement request is not > a good idea... I am not sure. Although the template system already does pretty clever deductions, I think they are all based on hints given by the programmer. They work "forward" from the rules. However, both in your example above and in ted's code, the compiler has to solve a problem similar to declarative programming languages to arrive at the intent. For example, it must apply sqrt to the second length to figure out N. Admittedly, it is not apparent in the code above because the first parameter is already trivially N so the human reader thinks "N comes from the first argument and it must also satisfy the second argument". The following would ask the compiler to work backward from the argument: void bar(size_t N)(int[N ^^ 2] b) {} "Take a value from the argument, take its square root and then use that value to figure out the instantiation value of this template." Ali
Re: Classes and @disable this()
On Monday, February 09, 2015 15:25:14 Steven Schveighoffer via Digitalmars-d-learn wrote: > Well, if I do this: > > class C {} > > I can do this: > > new C(); > > Mechanisms to disable this are kind of awkward. I can define this() as > private, but that doesn't help for intra-module calls. > > static class C doesn't work. > > It really is only useful in the case where you don't want to define a > constructor. Which probably means -- you don't want to use a class anyway ;) > > But for completeness, it seems like I should be able to have the option > of disabling something the compiler does by default. Even if it's next > to useless. I suppose that it makes sense if you want to make it so that the class can't be constructed (and actually, now that I look at it, that's what std.datetime.Clock does), but if another constructor has been declared, then it should be probably be disallowed at compile time - especially if it's resulting in a linker error. - Jonathan M Davis
Re: Classes and @disable this()
I think this can be filed in Bugzilla as diagnostic enhancement: class Foo { @disable this(); this(int i) {} } void main() {} https://issues.dlang.org/show_bug.cgi?id=14163 Bye, bearophile
Re: "cannot deduce function from argument types" issue.
bearophile wrote: > ted: > >> Could someone enlighten me ? > > This works: > > > import std.range: ElementType, isInputRange; > > ElementType!R testFunc(R, T)(R range, T foo) > if (is(ElementType!R == T)) { > static assert(isInputRange!R); > typeof(return) retVal = foo ^^ 2; // More DRY. > return retVal; > } > > void main() { > auto values = [0.0, 3.0, -1.0, 5.0]; > auto result = testFunc(values, 8.8); > } > > > The D compiler seems unable to compute ElementType!R in the > function signature. If I am right, then this seems worth an > enhancement request. > > Bye, > bearophile thanks !... ... where you say 'More DRY' above, are you referring to - foo^^2 ( I just did foo*foo for the sake of the example), or - typeof(return) - a construct I am completely unfamiliar with and will now have to look up ! If it is 'typeof(return)' why would this be selected over ElementType!R ?? Is it more idiomatic ? regards, ted
Re: "cannot deduce function from argument types" issue.
void bar(size_t N)(int[N] a, int[N ^ 2] b) {} I meant: void bar(size_t N)(int[N] a, int[N ^^ 2] b) {}
Re: "cannot deduce function from argument types" issue.
Ali Çehreli wrote: > On 02/10/2015 12:31 AM, ted wrote: > > > ElementType!R testFunc(R)( R range, ElementType!R foo) // compiles > > with double foo > > If think it is a little too much to ask from the template system of D. A > proper way of doing the same thing is to use a template constraint: > > ElementType!R testFunc(R, E)( R range, E foo) > if (is (E : ElementType!R)) > > Ali thanks !
Re: "cannot deduce function from argument types" issue.
Ali Çehreli: If think it is a little too much to ask from the template system of D. I remember hitting a similar problem with code like this bar() function: // OK void foo(size_t N1, size_t N2)(int[N1] a, int[N2] b) if (N2 == N1 ^^ 2) {} // Not OK void bar(size_t N)(int[N] a, int[N ^ 2] b) {} void main() { int[2] a = [1, 2]; int[4] b = [1, 2, 3, 4]; foo(a, b); bar(a, b); } So perhaps my suggestion to file an enhancement request is not a good idea... Bye, bearophile
Re: "cannot deduce function from argument types" issue.
On 02/10/2015 12:31 AM, ted wrote: > ElementType!R testFunc(R)( R range, ElementType!R foo) // compiles with > double foo If think it is a little too much to ask from the template system of D. A proper way of doing the same thing is to use a template constraint: ElementType!R testFunc(R, E)( R range, E foo) if (is (E : ElementType!R)) Ali
Re: "cannot deduce function from argument types" issue.
ted: Could someone enlighten me ? This works: import std.range: ElementType, isInputRange; ElementType!R testFunc(R, T)(R range, T foo) if (is(ElementType!R == T)) { static assert(isInputRange!R); typeof(return) retVal = foo ^^ 2; // More DRY. return retVal; } void main() { auto values = [0.0, 3.0, -1.0, 5.0]; auto result = testFunc(values, 8.8); } The D compiler seems unable to compute ElementType!R in the function signature. If I am right, then this seems worth an enhancement request. Bye, bearophile
Re: To write such an expressive code D
On Tuesday, 10 February 2015 at 08:40:38 UTC, Dennis Ritchie wrote: Because I was arguing with one quiet a stubborn person who does not like D, on this forum: http://www.cyberforum.ru/holywars/thread1367892-page13.html He asked me to write such a program using only the language features and functions sin(). If someone makes stupid demands like this one to justify his dislike for the language, such person is either deliberate troll or has strong enough prejudice no never like language anyway, arguments or not. Language features don't magically appear from nowhere - those come at cost of extra code in compiler and/or runtime library making it very hard to use language with smaller runtime (D is actually guilty of that). It is a common practice to treat standard language library as part of language. Both C and C++ include detailed spec on standard library in official language spec for example. As such making any distinction between two is impractical.
Re: To write such an expressive code D
On Tuesday, 10 February 2015 at 08:40:38 UTC, Dennis Ritchie wrote: On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote: Why is that? Потому что я спорил с одним упёртым человеком, которому не нравится D, на этом форуме: http://www.cyberforum.ru/holywars/thread1367892-page13.html Он просил меня написать такую программу с использованием только возможностей языка и функции sin(). Because I was arguing with one quiet a stubborn person who does not like D, on this forum: http://www.cyberforum.ru/holywars/thread1367892-page13.html He asked me to write such a program using only the language features and functions sin(). How to win the holy language war: 1. Pick a feature that only one of the languages has 2. Pick a task that this feature solves neatly 3. Solve it using that feature 4. Forbid every other solution not involving the features that only your preferred language has. Done.
Re: To write such an expressive code D
On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote: Why is that? Потому что я спорил с одним упёртым человеком, которому не нравится D, на этом форуме: http://www.cyberforum.ru/holywars/thread1367892-page13.html Он просил меня написать такую программу с использованием только возможностей языка и функции sin(). Because I was arguing with one quiet a stubborn person who does not like D, on this forum: http://www.cyberforum.ru/holywars/thread1367892-page13.html He asked me to write such a program using only the language features and functions sin().
"cannot deduce function from argument types" issue.
Hi! I get the following compile error (linux, dmd2.066.1): test.d(13): Error: template test.testFunc cannot deduce function from argument types !()(double[], double), candidates are: test.d(3):test.testFunc(R)(R range, ElementType!R foo) For the following test file: import std.range: ElementType, isInputRange; ElementType!R testFunc(R)( R range, ElementType!R foo) // compiles with double foo { static assert( isInputRange!R ); ElementType!R retVal = foo*foo; return retVal; } void main() { double[] values = [0.0, 3.0, -1.0, 5.0]; auto result = testFunc( values, 8.8 ); } And I'm not sure what I'm doing incorrectly. It compiles/works fine if I hardcode the type for foo. Could someone enlighten me ? regards, ted
Re: To write such an expressive code D
On Tuesday, 10 February 2015 at 04:17:48 UTC, Dennis Ritchie wrote: I just need that code was only used features of the language without using library functions. You may only use the function sin(). Why is that? Although D has a lot of language features, D tries to push functionality into the library as often as possible. This is better than having language features for everything, because you can then reimplement, tweak or replace said features by simply writing D code.
Re: How to write similar code D?
FG: auto query = iota(2, 2 + 10) .map!(c => ["Length": 2 * c, "Height": c * c - 1, "Hypotenuse": c * c + 1]) .map!(x => format("%4d%4d%4d", x["Height"], Unlike other languages like JavaScript, the D front-end is very weak in optimizing well such kind of code... I think D compilers handle built-in associative arrays in a very straight way. Bye, bearophile