Re: Abstract Classes

2017-12-05 Thread Ali Çehreli via Digitalmars-d-learn
On 12/05/2017 11:23 PM, IM wrote: Assume the following: interface IFace {   void foo();   void bar(); } abstract class A : IFace {   override void foo() {} } class B : A {   override void bar() {} } Now why this fails to compiler with the following message: --->>> function bar does not

Abstract Classes

2017-12-05 Thread IM via Digitalmars-d-learn
Assume the following: interface IFace { void foo(); void bar(); } abstract class A : IFace { override void foo() {} } class B : A { override void bar() {} } Now why this fails to compiler with the following message: --->>> function bar does not override any function, did you mean to

Re: git workflow for D

2017-12-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 06, 2017 04:56:17 Arun Chandrasekaran via Digitalmars-d-learn wrote: > Looks like Mercurial is going to be rewritten in Rust > https://www.mercurial-scm.org/wiki/OxidationPlan > > So Facebook don't use D? As I understand it, the main languages at Facebook are C++ and PHP,

Re: git workflow for D

2017-12-05 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Monday, 4 December 2017 at 01:26:45 UTC, Arun Chandrasekaran wrote: On Sunday, 3 December 2017 at 23:39:49 UTC, Basile B. wrote: [...] If you still lose changes, you could try using Mercurial with hggit. It can be a bit slow, but not destructive as git itself. ;) I really wish

Re: lower case only first letter of word

2017-12-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/5/17 2:41 PM, kdevel wrote: On Tuesday, 5 December 2017 at 17:25:57 UTC, Steven Schveighoffer wrote: [...] struct LowerCaseFirst(R) // if(isSomeString!R) {    R src;    bool notFirst; // terrible name, but I want default false    dchar front() {   import std.uni: toLower;   return

cannot deduce template lambda from argument

2017-12-05 Thread aliak via Digitalmars-d-learn
Hi, Having a little trouble understanding lambda type deduction. I have this lambda: immutable lambda(T) = (T n) => n * n; and if I call it with an explicit type it works else it errors with: lambda cannot deduce function from argument types !()(int) auto x = lambda!int(2); // ok auto x =

Re: StopWatch problem

2017-12-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 05, 2017 14:25:12 Ali Çehreli via Digitalmars-d-learn wrote: > Selective imports complicates matters. Changing the imports lets it > compile with 2.076: > > void main() { > import std.datetime; > import std.stdio: writeln; > > StopWatch sw; >

Re: StopWatch problem

2017-12-05 Thread Ali Çehreli via Digitalmars-d-learn
On 12/05/2017 01:45 PM, Jonathan M Davis wrote: > On Tuesday, December 05, 2017 21:33:53 Joel via Digitalmars-d-learn wrote: >> void main() { >>import std.datetime: Duration, msecs; >>import std.datetime.stopwatch: StopWatch; >> >>StopWatch sw; >>if (sw.peek.msecs) { >> >>}

Re: StopWatch problem

2017-12-05 Thread Joel via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 21:45:20 UTC, Jonathan M Davis wrote: On Tuesday, December 05, 2017 21:33:53 Joel via Digitalmars-d-learn wrote: [...] core.time.msecs is an alias for core.time.dur!"msecs". It takes a long for the number of milliseconds and returns a Duration. If you want to

Re: StopWatch problem

2017-12-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 05, 2017 21:33:53 Joel via Digitalmars-d-learn wrote: > void main() { > import std.datetime: Duration, msecs; > import std.datetime.stopwatch: StopWatch; > > StopWatch sw; > if (sw.peek.msecs) { > > } > } > > I get this error with the code: > z.d(6): Error: function

StopWatch problem

2017-12-05 Thread Joel via Digitalmars-d-learn
void main() { import std.datetime: Duration, msecs; import std.datetime.stopwatch: StopWatch; StopWatch sw; if (sw.peek.msecs) { } } I get this error with the code: z.d(6): Error: function core.time.dur!"msecs".dur (long length) is not

Re: lower case only first letter of word

2017-12-05 Thread Ali Çehreli via Digitalmars-d-learn
On 12/05/2017 11:41 AM, kdevel wrote: On Tuesday, 5 December 2017 at 17:25:57 UTC, Steven Schveighoffer wrote: But one cannot use the return value of lowerCaseFirst as argument for foo(string). Only the use as argument to writeln seems to work. That's how ranges work. LowerCaseFirst

Re: lower case only first letter of word

2017-12-05 Thread kdevel via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 17:25:57 UTC, Steven Schveighoffer wrote: [...] struct LowerCaseFirst(R) // if(isSomeString!R) { R src; bool notFirst; // terrible name, but I want default false dchar front() { import std.uni: toLower; return notFirst ? src.front :

Re: lower case only first letter of word

2017-12-05 Thread Ali Çehreli via Digitalmars-d-learn
On 12/05/2017 09:25 AM, Steven Schveighoffer wrote: Non-allocating version: struct LowerCaseFirst(R) // if(isSomeString!R) {    R src;    bool notFirst; // terrible name, but I want default false    dchar front() {   import std.uni: toLower;   return notFirst ? src.front :

Re: Embedded interfaces with generic members

2017-12-05 Thread A Guy With a Question via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 19:27:37 UTC, Ali Çehreli wrote: On 12/05/2017 11:07 AM, A Guy With a Question wrote: > The following doesn't appear to be valid syntax. Array!Item!T You can ommit the template argument list parenteses only for single symbols. Starting with the full syntax:

Re: Embedded interfaces with generic members

2017-12-05 Thread Ali Çehreli via Digitalmars-d-learn
On 12/05/2017 11:07 AM, A Guy With a Question wrote: > The following doesn't appear to be valid syntax. Array!Item!T You can ommit the template argument list parenteses only for single symbols. Starting with the full syntax: Array!(Item!(T)) Since Item!(T) uses a single symbol, T, you can

Embedded interfaces with generic members

2017-12-05 Thread A Guy With a Question via Digitalmars-d-learn
The following doesn't appear to be valid syntax. Array!Item!T I get the following error: "multiple ! arguments are not allowed" Which is ok...I get THAT error, however, this does not work either: alias Items(T) = Array!Item(T); This gives me the error: Error: function declaration

Re: git workflow for D

2017-12-05 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 04, 2017 at 12:02:37PM -0800, Ali Çehreli via Digitalmars-d-learn wrote: [...] > Paraphrasing someone I trust very much, "Never 'pull', always 'fetch > -p' and then rebase." I always use `git pull --ff-only`. Lets me pull when it's "safe", aborts if it will end up in a mess (i.e.,

Re: git workflow for D

2017-12-05 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Dec 04, 2017 at 06:51:42AM -0500, Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > On 12/03/2017 03:05 PM, bitwise wrote: > > I've finally started learning git, due to our team expanding beyond > > one person - awesome, right? > > PROTIP: Version control systems (no matter

Re: lower case only first letter of word

2017-12-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/5/17 10:00 AM, Mengu wrote: On Tuesday, 5 December 2017 at 14:34:57 UTC, Mengu wrote: On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote: On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: [...] Yes, this is not what I want. I want to convert only the first letter

Directory Size

2017-12-05 Thread Vino via Digitalmars-d-learn
Hi All, Is there any better ways to get the size of folders , The below code perfectly works , but i need return type as Array!(Tuple!(string, string)) rather then using the "Result.insertBack(d); Result.insertBack(to!string(SdFiles[].sum))" as per the below example. E.g:

Re: git workflow for D

2017-12-05 Thread John Gabriele via Digitalmars-d-learn
On Sunday, 3 December 2017 at 20:05:47 UTC, bitwise wrote: {snip} If anyone can offer any kind of advice, or an article that explains these things concisely and effectively, that would be helpful. I found some git-specific info in this wiki page:

Re: Object oriented programming and interfaces

2017-12-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/4/17 3:43 PM, Dirk wrote: Hi! I defined an interface: interface Medoid {     float distance( Medoid other );     uint id() const @property; } and a class implementing that interface: class Item : Medoid {     float distance( Item i ) {...}     uint id() const @property {...} } The

Re: Passing Function as an argument to another Function

2017-12-05 Thread Vino via Digitalmars-d-learn
On Monday, 4 December 2017 at 19:25:15 UTC, Ali Çehreli wrote: On 12/04/2017 04:52 AM, Vino wrote: > [...] Every expression has a type. 'auto' in that context (or 'const', etc.) just helps with not spelling-out that type. You can see the type with pragma(msg) and typeof: [...] Hi Ali,

Re: git workflow for D

2017-12-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/4/17 3:14 PM, Ali Çehreli wrote: Dear git experts, given 3 repos, now what are the steps? Is the following correct? What are the exact commands? Disclaimer: I'm not a git expert. - Only once, create the original repo as an upstream of your local repo. The wording is off

Re: lower case only first letter of word

2017-12-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-05 15:34, Mengu wrote: this is how i'd do it: string upcaseFirst(string wut) {   import std.ascii : toUpper;   import std.array : appender;   auto s = appender!string;   s ~= wut[0].toUpper;   s ~= wut[1..$];   return s.data; } That's not Unicode aware and is only safe to

Re: git workflow for D

2017-12-05 Thread Jesse Phillips via Digitalmars-d-learn
I'm going to answer with something that others may not agree with, maybe they can enlighten me, but let me first get a generic principle of git and answer some questions. Git has 2 types of branches, local branches (you know them as just branches) and remotes (which have their own local

Re: Object oriented programming and interfaces

2017-12-05 Thread Jesse Phillips via Digitalmars-d-learn
On Monday, 4 December 2017 at 20:43:27 UTC, Dirk wrote: Hi! I defined an interface: interface Medoid { float distance( Medoid other ); uint id() const @property; } and a class implementing that interface: class Item : Medoid { float distance( Item i ) {...} uint id() const

Re: lower case only first letter of word

2017-12-05 Thread Mengu via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 14:34:57 UTC, Mengu wrote: On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote: On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: [...] Yes, this is not what I want. I want to convert only the first letter of the word to lower case and left

Re: lower case only first letter of word

2017-12-05 Thread Mengu via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote: On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: but this will change all other uppercase to lowercase, so maybe it is not what you want. If you really want just change first char to upper, then there is nothing wrong to

Re: lower case only first letter of word

2017-12-05 Thread Marc via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: but this will change all other uppercase to lowercase, so maybe it is not what you want. If you really want just change first char to upper, then there is nothing wrong to do it yourself On Tue, Dec 5, 2017 at 2:37 PM, Daniel

No line numbers in stack trace (again)

2017-12-05 Thread Nordlöw via Digitalmars-d-learn
If I get the following stack trace ___without line numbers___ (instead ??:?) what's missing? core.exception.AssertError@src/knet/linking.d(444): Assertion failure ??:? _d_assertp [0x5092ab19] ??:? pure @safe knet.storage.Edge

Re: lower case only first letter of word

2017-12-05 Thread Daniel Kozak via Digitalmars-d-learn
but this will change all other uppercase to lowercase, so maybe it is not what you want. If you really want just change first char to upper, then there is nothing wrong to do it yourself On Tue, Dec 5, 2017 at 2:37 PM, Daniel Kozak wrote: > Something like this:

Re: lower case only first letter of word

2017-12-05 Thread ketmar via Digitalmars-d-learn
Marc wrote: Does D have a native function to capitalize only the first letter of the word? (I'm asking that so I might avoid reinvent the wheel, which I did sometimes in D) http://dpldocs.info/experimental-docs/std.string.capitalize.html

Re: lower case only first letter of word

2017-12-05 Thread Daniel Kozak via Digitalmars-d-learn
Something like this: https://dlang.org/phobos/std_uni.html#asCapitalized On Tue, Dec 5, 2017 at 2:31 PM, Marc via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Does D have a native function to capitalize only the first letter of the > word? (I'm asking that so I might avoid

lower case only first letter of word

2017-12-05 Thread Marc via Digitalmars-d-learn
Does D have a native function to capitalize only the first letter of the word? (I'm asking that so I might avoid reinvent the wheel, which I did sometimes in D)

Re: Python and D (PyD)

2017-12-05 Thread Fat_Umpalumpa via Digitalmars-d-learn
Omg this was working a few days ago just fine! Now I can't even start the histogram example! I haven't changed the code and I know this worked a week ago. dub still builds the program, however now when running the program, I get an error

Re: Object oriented programming and interfaces

2017-12-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 07:47:32 UTC, Dirk wrote: The distance function is implementation dependend and can only be computed between two objects of the same class (in this example the class is Item). Just don't put it in the interface. Leave it in the individual classes with the

Re: Object oriented programming and interfaces

2017-12-05 Thread bauss via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 08:08:55 UTC, Daniel Kozak wrote: You can do something like this: interface Medoid(T) { float distance( T other ); uint id() const @property; } class Item : Medoid!(Item) { float distance( Item m ) { return 0.;} uint id() const @property { return

Re: Object oriented programming and interfaces

2017-12-05 Thread Daniel Kozak via Digitalmars-d-learn
You can do something like this: interface Medoid(T) { float distance( T other ); uint id() const @property; } class Item : Medoid!(Item) { float distance( Item m ) { return 0.;} uint id() const @property { return 1; } } class MedoidClassification { this(T:Medoid!T)(T[] list)

Re: Object oriented programming and interfaces

2017-12-05 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 07:47:32 UTC, Dirk wrote: What would be a good way to implement this? Did you tried to use introspection?