Re: why --shebang for rdmd?

2015-11-21 Thread Marc Schütz via Digitalmars-d-learn
On Saturday, 21 November 2015 at 05:20:16 UTC, Shriramana Sharma wrote: Hello. The following code works fine for me: #! /usr/bin/env rdmd import std.stdio; void main() { writeln(2); } So what is the use of the --shebang option of rdmd? http://dlang.org/rdmd.html does not shed much light on

Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread SimonN via Digitalmars-d-learn
string a = "hello"; string b = a[3 .. 2]; I expect b to become an empty slice, because 3 is >= 2 already after 0 increments, making the slice length 0. Instead, the code throws a range violation. Expressions of this kind come up, e.g., when taking slices near the end of arrays, like

Re: GTKD - Create a simple TextBox?

2015-11-21 Thread kaiyori via Digitalmars-d-learn
On Saturday, 21 November 2015 at 15:57:35 UTC, TheDGuy wrote: Hello, i haven't found any tutorial about creating a textbox with GTKD yet, so maybe someone could show me how to do it? How About gtk.TextView ?

Re: D equivalent of Python's try..else

2015-11-21 Thread Shriramana Sharma via Digitalmars-d-learn
Russel Winder via Digitalmars-d-learn wrote: > else on for and while, whilst technically redundant as well, does > occasionally make for a nicer read, for very analogous reasons. It can > generally avoid the need for extra booleans and other state variables. Hmm – I forgot Python has `else` for

Re: dataframe implementations

2015-11-21 Thread Laeeth Isharc via Digitalmars-d-learn
On Thursday, 19 November 2015 at 22:14:01 UTC, ZombineDev wrote: On Thursday, 19 November 2015 at 06:33:06 UTC, Jay Norwood wrote: On Wednesday, 18 November 2015 at 22:46:01 UTC, jmh530 wrote: My sense is that any data frame implementation should try to build on the work that's being done with

"final" as function parameter attribute?

2015-11-21 Thread Johan Engelen via Digitalmars-d-learn
On http://dlang.org/function.html, I read that "final" is a valid attribute/storage class for function parameters: InOutX: auto TypeCtor final <-- ?? in lazy out ref scope This looks like a documentation error, but perhaps it's not. I hope someone can explain

Re: D equivalent of Python's try..else

2015-11-21 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2015-11-21 at 19:26 +0530, Shriramana Sharma via Digitalmars-d- learn wrote: > […] > Hmm – I forgot Python has `else` for `for` and `while` too. But it's > a tad > difficult to wrap one's mind around the meaning of the word `else` in > this > particular context whereas it actually means

Re: Compile time strings auto concatenation!?

2015-11-21 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 20 November 2015 at 20:39:58 UTC, Ilya wrote: Can DMD frontend optimize string concatenation ``` enum Double(S) = S ~ S; assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); ``` to ``` assert(condition, "Text ++_function_name_"); ``` ? At least for string (and array?)

Case-insensitive BoyerMooreFinder

2015-11-21 Thread Ralf via Digitalmars-d-learn
Hi, I just spend a day with the D programming language and I am very excited about being able to write such performant programs in such an clear and concise way! I tried to write a little search tool. The BoyerMooreFinder docs say that the comparison operator can be specified.

Re: Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread BBaz via Digitalmars-d-learn
On Saturday, 21 November 2015 at 18:03:07 UTC, SimonN wrote: string a = "hello"; string b = a[3 .. 2]; I expect b to become an empty slice, because 3 is >= 2 already after 0 increments, making the slice length 0. Instead, the code throws a range violation. Expressions of this kind

Re: Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread SimonN via Digitalmars-d-learn
On Saturday, 21 November 2015 at 18:28:51 UTC, BBaz wrote: this is only an error if bounds checking is not turned on. If you compile your example with DMD option "-boundscheck=off", nothing happens, and the slice will be equal (here) to a[3..$]; Thanks for the hint, I tested this with

GTKD - Create a simple TextBox?

2015-11-21 Thread TheDGuy via Digitalmars-d-learn
Hello, i haven't found any tutorial about creating a textbox with GTKD yet, so maybe someone could show me how to do it?

Re: `finally` is redundant?

2015-11-21 Thread Chris Wright via Digitalmars-d-learn
On Sat, 21 Nov 2015 11:15:22 +0530, Shriramana Sharma wrote: > The page http://dlang.org/exception-safe.html says: > > "It's try-finally that becomes redundant." > > IIUC this is because we have scope(exit). > > Does this mean that `finally` should eventually be removed from the > language?

Re: Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 18:28:49 BBaz via Digitalmars-d-learn wrote: > this is only an error if bounds checking is not turned on. If you > compile your example with DMD option "-boundscheck=off", nothing > happens, and the slice will be equal (here) to a[3..$]; It's a logic error

Re: `finally` is redundant?

2015-11-21 Thread Meta via Digitalmars-d-learn
On Saturday, 21 November 2015 at 05:45:25 UTC, Shriramana Sharma wrote: The page http://dlang.org/exception-safe.html says: "It's try-finally that becomes redundant." IIUC this is because we have scope(exit). Does this mean that `finally` should eventually be removed from the language? The

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 22, 2015 03:19:54 Jon D via Digitalmars-d-learn wrote: > On Sunday, 22 November 2015 at 00:31:53 UTC, Jonathan M Davis > wrote: > > > > Honestly, arrays suck as output ranges. They don't get appended > > to; they get filled, and for better or worse, the documentation > > for

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jon D via Digitalmars-d-learn
On Sunday, 22 November 2015 at 00:10:07 UTC, Ali Çehreli wrote: May I suggest that you improve that page. ;) If you don't already have a clone o the repo, you can do it easily by clicking the "Improve this page" button on that page. Hi Ali, thanks for the quick response. And point taken :) I

Re: `finally` is redundant?

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 22, 2015 02:00:46 Chris Wright via Digitalmars-d-learn wrote: > On Sat, 21 Nov 2015 16:10:45 -0800, Jonathan M Davis via > Digitalmars-d-learn wrote: > > > Getting rid of finally would mean > > reimplementing scope(exit) differently > > Well, we could keep try/finally as a

Re: DFLAGS ignored. How to get a dmd installation on windows that is 64 bit only

2015-11-21 Thread Rikki Cattermole via Digitalmars-d-learn
On 22/11/15 7:34 PM, Carl Sturtivant wrote: The docs for dmd for windows say that the DFLAGS environment variable's value will be appended to the dmd command line. I tried this with -m64 as the value and this is ignored. http://dlang.org/dmd-windows.html#environment More generally, is there a

Re: D equivalent of Python's try..else

2015-11-21 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 21 November 2015 at 13:57:01 UTC, Shriramana Sharma wrote: Hmm – I forgot Python has `else` for `for` and `while` too. But it's a tad difficult to wrap one's mind around the meaning of the word `else` in this particular context whereas it actually means `nobreak`. Perhaps if

DFLAGS ignored. How to get a dmd installation on windows that is 64 bit only

2015-11-21 Thread Carl Sturtivant via Digitalmars-d-learn
The docs for dmd for windows say that the DFLAGS environment variable's value will be appended to the dmd command line. I tried this with -m64 as the value and this is ignored. http://dlang.org/dmd-windows.html#environment More generally, is there a standard rearrangement of files and

copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jon D via Digitalmars-d-learn
Something I found confusing was the relationship between array capacity and copy(). A short example: void main() { import std.algorithm: copy; auto a = new int[](3); assert(a.length == 3); [1, 2, 3].copy(a); // Okay int[] b; b.reserve(3); assert(b.capacity >=

Re: "final" as function parameter attribute?

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 15:14:31 Johan Engelen via Digitalmars-d-learn wrote: > On http://dlang.org/function.html, I read that "final" is a valid > attribute/storage class for function parameters: > > InOutX: > auto > TypeCtor > final <-- ?? > in > lazy > out

Re: `finally` is redundant?

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 11:15:22 Shriramana Sharma via Digitalmars-d-learn wrote: > The page http://dlang.org/exception-safe.html says: > > "It's try-finally that becomes redundant." > > IIUC this is because we have scope(exit). > > Does this mean that `finally` should eventually be

Re: Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 18:03:05 SimonN via Digitalmars-d-learn wrote: > string a = "hello"; > string b = a[3 .. 2]; > > I expect b to become an empty slice, because 3 is >= 2 already > after 0 increments, making the slice length 0. Instead, the code > throws a range violation. >

Building the Docs with checked out code downoads old dmd

2015-11-21 Thread yawniek via Digitalmars-d-learn
i'm trying to build the docs as per http://wiki.dlang.org/Building_DMD#Building_the_Docs i have a working setup to build the latest dmd/druntime/phobos but somehow the makefile tries to download an old dmd version and my bandwith currently is a bit restricted and i want an offline version.

Re: Building the Docs with checked out code downoads old dmd

2015-11-21 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Nov 21, 2015 at 08:29:51PM +, yawniek via Digitalmars-d-learn wrote: > i'm trying to build the docs as per > http://wiki.dlang.org/Building_DMD#Building_the_Docs > > i have a working setup to build the latest dmd/druntime/phobos but > somehow the makefile tries to download an old dmd

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Ali Çehreli via Digitalmars-d-learn
Hi Jon! :) On 11/21/2015 03:34 PM, Jon D wrote: > Preconditions: > target shall have enough room to accomodate the entirety of source. > > Clarifying that "enough room" means 'length' rather than 'capacity' > might be beneficial. May I suggest that you improve that page. ;) If you

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 23:34:25 Jon D via Digitalmars-d-learn wrote: > Something I found confusing was the relationship between array > capacity and copy(). A short example: > > void main() > { > import std.algorithm: copy; > > auto a = new int[](3); > assert(a.length == 3);

Re: `finally` is redundant?

2015-11-21 Thread Chris Wright via Digitalmars-d-learn
On Sat, 21 Nov 2015 16:10:45 -0800, Jonathan M Davis via Digitalmars-d-learn wrote: > Getting rid of finally would mean > reimplementing scope(exit) differently Well, we could keep try/finally as a concept inside the compiler but change the parser so it rejects finally blocks.

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jon D via Digitalmars-d-learn
On Sunday, 22 November 2015 at 00:31:53 UTC, Jonathan M Davis wrote: Honestly, arrays suck as output ranges. They don't get appended to; they get filled, and for better or worse, the documentation for copy is probably assuming that you know that. If you want your array to be appended to when

Re: Range violation instead of empty slice on a[3 .. 2]

2015-11-21 Thread SimonN via Digitalmars-d-learn
On Sunday, 22 November 2015 at 00:24:43 UTC, Jonathan M Davis wrote: this is only an error if bounds checking is not turned on. It's a logic error regardless. you're going to have to create a wrapper. Right, I am using a wrapper, and I'm not relying on any behavior of a[3..2] during

Re: Compile time strings auto concatenation!?

2015-11-21 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 20 November 2015 at 20:39:58 UTC, Ilya wrote: Can DMD frontend optimize string concatenation ``` enum Double(S) = S ~ S; assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); ``` to ``` assert(condition, "Text ++_function_name_"); ``` ? If you really want to make sure it is

Re: Manually allocate delegate?

2015-11-21 Thread Jack Applegame via Digitalmars-d-learn
On Sunday, 12 July 2015 at 08:38:01 UTC, Tofu Ninja wrote: Is it even possible? You can use function instead delegate, and bind captured variables as struct: http://dpaste.dzfl.pl/6e23bbcfe17f auto bind(F: R function(ARGS), R, ARGS...)(F fn, ARGS args) @nogc { struct Functor {

Re: D equivalent of Python's try..else

2015-11-21 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2015-11-20 at 22:39 -0800, Ali Çehreli via Digitalmars-d-learn wrote: > […] > I don't know what idiom that enables in Python but it feels to me > like > putting the statements right after the ones that could throw suffices > in > D (and Python): The else clause for while, for, try, has

Re: Manually allocate delegate?

2015-11-21 Thread Tofu Ninja via Digitalmars-d-learn
On Saturday, 21 November 2015 at 00:30:45 UTC, userABCabc123 wrote: Yes: class Foo { void bar(){writeln(__PRETTY_FUNCTION__);} } auto uncollectedDelegate(T, string name)(ref T t) { import std.experimental.allocator.mallocator; struct Dg{void* ptr,

Can someone check this on win32 ?

2015-11-21 Thread BBaz via Digitalmars-d-learn
Seems to be fixed: __ import std.math; void main() {real function(real) c = } __ https://issues.dlang.org/show_bug.cgi?id=4541 At least it works on linux x86_64.

Re: Build utf.d with MS-COFF failed

2015-11-21 Thread Pierre via Digitalmars-d-learn
On Saturday, 21 November 2015 at 01:18:38 UTC, Charles wrote: What string is throwing the error? I've had that error when I was trying to decode windows1252 strings. Thank you for your answer, but it's not a compilation error, it's a message box displayed when i lauch compilation. I asked