Re: Casting in Safe D

2014-11-27 Thread Nordlöw
On Thursday, 27 November 2014 at 00:27:59 UTC, David Held wrote: On 11/23/2014 3:12 PM, anonymous wrote: [...] And even pointer dereferencing is @safe. Invalid ones will fail with a segfault at run time: void foo(int* a) @safe {*a = 13;} Hmm...throwing an exception is a well-defined behavior,

[dub] Size of executable

2014-11-27 Thread Chris via Digitalmars-d-learn
[Maybe this has been asked before.] I usually use dub to create and build projects. I built one of the projects with dub and then by hand with dmd[1] passing all the files etc. Turned out that the executable built with dub was 1.4 MB whereas the one built by hand was only 807 kB. Why is that?

[dub] Size of executable

2014-11-27 Thread Chris via Digitalmars-d-learn
[Maybe this has been asked before.] I usually use dub to create and build projects. I built one of the projects with dub and then by hand with dmd[1] passing all the files etc. Turned out that the executable built with dub was 1.4 MB whereas the one built by hand was only 807 kB. Why is that?

Re: windows linker error

2014-11-27 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 26 November 2014 at 04:10:08 UTC, Vlad Levenfeld wrote: So I used the dmd visual studio project to build dmd It can be outdated, because dmd release is built by dmc, not vc.

Re: [dub] Size of executable

2014-11-27 Thread Gary Willoughby via Digitalmars-d-learn
On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote: I usually use dub to create and build projects. I built one of the projects with dub and then by hand with dmd[1] passing all the files etc. Turned out that the executable built with dub was 1.4 MB whereas the one built by hand was

Re: Error: cannot return non-void from void function

2014-11-27 Thread Suliman via Digitalmars-d-learn
Full function look like this: auto parseConfig() { auto config = Ini.Parse(getcwd ~ \\ ~ config.ini); string txtlinks = getcwd ~ \\ ~ config.getKey(input_links); if(!exists(txtlinks)) { writeln(Can't find input file with list of links.);

Error: cannot return non-void from void function

2014-11-27 Thread Suliman via Digitalmars-d-learn
auto parseConfig() { auto lines = File(txtlinks, r).byLine; return lines; } Error: cannot return non-void from void function I can't understand the reasons of the error; Can I return auto from function?

function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Suliman via Digitalmars-d-learn
I try to compile simple example: import std.net.curl; void main() { download(ftp.digitalmars.com/sieve.ds, D:\\Project\\2014\\txt_downloader\\img\\1.foo); } but I am getting error: function app.download (string[] links) is not callableusing argument types (string, string)

Re: Error: cannot return non-void from void function

2014-11-27 Thread Graham Fawcett via Digitalmars-d-learn
On Thursday, 27 November 2014 at 13:07:59 UTC, Suliman wrote: Full function look like this: auto parseConfig() { auto config = Ini.Parse(getcwd ~ \\ ~ config.ini); string txtlinks = getcwd ~ \\ ~ config.getKey(input_links); if(!exists(txtlinks)) {

Re: [dub] Size of executable

2014-11-27 Thread Chris via Digitalmars-d-learn
On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby wrote: On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote: I usually use dub to create and build projects. I built one of the projects with dub and then by hand with dmd[1] passing all the files etc. Turned out that the

Re: [dub] Size of executable

2014-11-27 Thread CraigDillabaugh via Digitalmars-d-learn
On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote: On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby wrote: On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote: I usually use dub to create and build projects. I built one of the projects with dub and then by hand

Re: [dub] Size of executable

2014-11-27 Thread Chris via Digitalmars-d-learn
On Thursday, 27 November 2014 at 13:59:23 UTC, CraigDillabaugh wrote: On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote: On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby wrote: On Thursday, 27 November 2014 at 09:33:49 UTC, Chris wrote: I usually use dub to create and

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Suliman via Digitalmars-d-learn
Look like it was missed installation or so. I installed new copy of dmd and error gone away.

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Suliman via Digitalmars-d-learn
The downloading still do not work. Work only: get(dlang.org);

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Evil Satanson via Digitalmars-d-learn
On Thursday, 27 November 2014 at 13:39:41 UTC, Suliman wrote: I try to compile simple example: import std.net.curl; void main() { download(ftp.digitalmars.com/sieve.ds, D:\\Project\\2014\\txt_downloader\\img\\1.foo); } but I am getting error: function app.download (string[] links) is not

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Evil Satanson via Digitalmars-d-learn
On Thursday, 27 November 2014 at 14:35:08 UTC, Daniel Kozák via Digitalmars-d-learn wrote: V Thu, 27 Nov 2014 13:39:40 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: I try to compile simple example: import std.net.curl; void main() {

attribute length missing in std.array: Appender

2014-11-27 Thread Andre via Digitalmars-d-learn
Hi, I implement a network protocol and use an Appender!(ubyte[])(). I have following issue. The first three bytes I have to fill, the following bytes are reserved and must be 0. In this example the overall header length must be 8. import std.array: appender; const HEADER_LENGTH = 8;

Re: Error: cannot return non-void from void function

2014-11-27 Thread ketmar via Digitalmars-d-learn
On Thu, 27 Nov 2014 13:07:58 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Full function look like this: auto parseConfig() { auto config = Ini.Parse(getcwd ~ \\ ~ config.ini); string txtlinks = getcwd ~ \\ ~ config.getKey(input_links);

Re: [dub] Size of executable

2014-11-27 Thread CraigDillabaugh via Digitalmars-d-learn
On Thursday, 27 November 2014 at 14:14:50 UTC, Chris wrote: On Thursday, 27 November 2014 at 13:59:23 UTC, CraigDillabaugh wrote: On Thursday, 27 November 2014 at 13:56:19 UTC, Chris wrote: On Thursday, 27 November 2014 at 12:29:03 UTC, Gary Willoughby wrote: On Thursday, 27 November 2014 at

Re: Error: cannot return non-void from void function

2014-11-27 Thread Suliman via Digitalmars-d-learn
ah, that's it! as spec says, D determines function return value from the first 'return' statement it seen. in your case this is `return;`, so function return type is determined to be `void`. if you doing `auto` functions, try to arrange your code so the first `return` returning the actual

Re: Error: cannot return non-void from void function

2014-11-27 Thread ketmar via Digitalmars-d-learn
On Thu, 27 Nov 2014 17:22:35 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: ah, that's it! as spec says, D determines function return value from the first 'return' statement it seen. in your case this is `return;`, so function return type is

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Suliman via Digitalmars-d-learn
Running .\txtdownloader.exe std.stream.OpenException@std\stream.d(50): Cannot open or create file 'D:\Projec t\2014\txt_downloader\img\1.foo' 0x0041BA59 in void std.stream.File.open(immutable(char)[], std.stream.FileMode) 0x00404B75 in void

Re: attribute length missing in std.array: Appender

2014-11-27 Thread via Digitalmars-d-learn
On Thursday, 27 November 2014 at 16:08:13 UTC, Andre wrote: Hi, I implement a network protocol and use an Appender!(ubyte[])(). I have following issue. The first three bytes I have to fill, the following bytes are reserved and must be 0. In this example the overall header length must be 8.

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Suliman via Digitalmars-d-learn
Is there any way to detect where collision was occurred?

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Suliman via Digitalmars-d-learn
Oh! It's work! I forgot to change path on my home PC!

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Suliman via Digitalmars-d-learn
On Thursday, 27 November 2014 at 17:39:10 UTC, Suliman wrote: Is there any way to detect where collision was occurred? It's look like collision was with method name.

Best way to add slash to tail of the path

2014-11-27 Thread Suliman via Digitalmars-d-learn
Sometimes it's path string may do not have tail slash of the path Compare: string path = C:\\folder\\name string path = C:\\folder\\name\\ in case if I need to append file name to path to get full path I can get error like: path ~= foo.txt C:\\folder\\namefoo.txt instead of

Re: Best way to add slash to tail of the path

2014-11-27 Thread ketmar via Digitalmars-d-learn
On Thu, 27 Nov 2014 18:05:37 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Sometimes it's path string may do not have tail slash of the path Compare: string path = C:\\folder\\name string path = C:\\folder\\name\\ in case if I need to append file name to

Re: [dub] Size of executable

2014-11-27 Thread Mike Wey via Digitalmars-d-learn
On 11/27/2014 03:14 PM, Chris wrote: dub says: Compiling using dmd... Linking... I have the exact same setting, I think. I don't build for release with either method. dmd file1.d file2.d file3.d ... (dub compiles the same files, no release build) dub builds with --debug by default. --

Re: Best way to add slash to tail of the path

2014-11-27 Thread Suliman via Digitalmars-d-learn
see std.path, it contains alot of useful things. I looked there, but found only buildNormalizedPath, but it's not for such situation...

Re: Best way to add slash to tail of the path

2014-11-27 Thread ketmar via Digitalmars-d-learn
On Thu, 27 Nov 2014 20:02:40 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: see std.path, it contains alot of useful things. I looked there, but found only buildNormalizedPath, but it's not for such situation... take a second look then. ;-) you'll find

Re: Best way to add slash to tail of the path

2014-11-27 Thread Suliman via Digitalmars-d-learn
take a second look then. ;-) you'll find `buildPath()` here too. Not better: string foo = D:/code/txtDownloader; writeln(foo); foo = foo.buildPath; foo ~= config.txt; writeln(foo); Running .\txtdownloader.exe D:/code/txtDownloader

Re: Best way to add slash to tail of the path

2014-11-27 Thread ketmar via Digitalmars-d-learn
On Thu, 27 Nov 2014 20:20:24 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: take a second look then. ;-) you'll find `buildPath()` here too. Not better: string foo = D:/code/txtDownloader; writeln(foo); foo = foo.buildPath; foo ~=

Re: Best way to add slash to tail of the path

2014-11-27 Thread Suliman via Digitalmars-d-learn
Could you quote for me part of docs where it's written? I really can't understand about what you are taking.

Re: Best way to add slash to tail of the path

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
Dne Thu, 27 Nov 2014 21:20:24 +0100 Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): take a second look then. ;-) you'll find `buildPath()` here too. Not better: string foo = D:/code/txtDownloader; writeln(foo); foo = foo.buildPath;

Re: Best way to add slash to tail of the path

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
try first few sentences and looked at the example ;) Dne Thu, 27 Nov 2014 21:42:31 +0100 Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): Could you quote for me part of docs where it's written? I really can't understand about what you are taking. -- Vytvořeno

Re: Best way to add slash to tail of the path

2014-11-27 Thread ketmar via Digitalmars-d-learn
On Thu, 27 Nov 2014 20:42:31 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Could you quote for me part of docs where it's written? I really can't understand about what you are taking. right here: http://dlang.org/phobos/std_path.html#buildPath do you see

Re: function app.download (string[] links) is not callableusing argument types (string, string)

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
Dne Thu, 27 Nov 2014 18:39:09 +0100 Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): Is there any way to detect where collision was occurred? Yes, read error description it has been app.download I guess -- Vytvořeno poštovní aplikací Opery:

Re: Best way to add slash to tail of the path

2014-11-27 Thread Suliman via Digitalmars-d-learn
thanks! I understood!

Re: Error: cannot return non-void from void function

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 27 November 2014 at 17:22:36 UTC, Suliman wrote: ah, that's it! as spec says, D determines function return value from the first 'return' statement it seen. in your case this is `return;`, so function return type is determined to be `void`. if you doing `auto` functions, try to

Re: Error: cannot return non-void from void function

2014-11-27 Thread ketmar via Digitalmars-d-learn
On Thu, 27 Nov 2014 21:14:57 + Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: import core.runtime; import std.c.process; writeln(Can't find input file with list of links.); Runtime.terminate();

Re: Error: cannot return non-void from void function

2014-11-27 Thread Daniel Kozak via Digitalmars-d-learn
Dne Thu, 27 Nov 2014 22:21:52 +0100 ketmar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): On Thu, 27 Nov 2014 21:14:57 + Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: import core.runtime; import

Re: Error: cannot return non-void from void function

2014-11-27 Thread ketmar via Digitalmars-d-learn
On Thu, 27 Nov 2014 22:25:10 +0100 Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Dne Thu, 27 Nov 2014 22:21:52 +0100 ketmar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsal(a): On Thu, 27 Nov 2014 21:14:57 + Daniel Kozak via

Re: Best way to add slash to tail of the path

2014-11-27 Thread Evil Satanson via Digitalmars-d-learn
On Thursday, 27 November 2014 at 20:52:26 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 27 Nov 2014 20:42:31 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Could you quote for me part of docs where it's written? I really can't understand about what you

thrift and dub

2014-11-27 Thread yawniek via Digitalmars-d-learn
hi, i'm trying to get a thrift example working within a dub project. it seems that the thrift.d in the dub repo is not whats actually needed but i should link against libthriftd.a that comes from the official thrift distro. what i tried is add the following to dub.json: libs:

Re: attribute length missing in std.array: Appender

2014-11-27 Thread andre via Digitalmars-d-learn
Thanks a lot for the help. Kind regards André On Thursday, 27 November 2014 at 17:29:50 UTC, Marc Schütz wrote: On Thursday, 27 November 2014 at 16:08:13 UTC, Andre wrote: Hi, I implement a network protocol and use an Appender!(ubyte[])(). I have following issue. The first three bytes I

Passing reference data to class and incapsulation

2014-11-27 Thread Uranuz via Digitalmars-d-learn
In D we a several data types which are passed by reference: dynamic arrays, associative arrays. And sometimes we need to pass these reference data to class instance to store it inside. One of the principles of object-oriented programming is incapsulation. So all class data should be only