Re: Object oriented programming and interfaces

2017-12-04 Thread Craig Dillabaugh 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: Object oriented programming and interfaces

2017-12-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 4 December 2017 at 20:43:27 UTC, Dirk wrote: 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 compiler

Re: git workflow for D

2017-12-04 Thread Ali Çehreli via Digitalmars-d-learn
On 12/04/2017 12:14 PM, Ali Çehreli wrote: 2) Rebase origin/master (on upstream, right?) 2.5) Create a branch and do all work on that branch 3) Make changes Ali

Object oriented programming and interfaces

2017-12-04 Thread Dirk via Digitalmars-d-learn
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 compiler says: Error: class Item

Re: Object oriented programming and interfaces

2017-12-04 Thread A Guy With a Question via Digitalmars-d-learn
On Monday, 4 December 2017 at 20:43:27 UTC, Dirk wrote: Hi! float distance( Medoid other ); float distance( Item i ) {...} The two signatures need to be the same. I think this is true of most OOP languages. Have them both be: float distance( Medoid other );

Re: Passing Function as an argument to another Function

2017-12-04 Thread Ali Çehreli via Digitalmars-d-learn
On 12/04/2017 04:52 AM, Vino wrote: > if the Variable CleanDirlst is defined as "auto" 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: auto someExpression = [ "one" : 1,

Re: git workflow for D

2017-12-04 Thread Ali Çehreli via Digitalmars-d-learn
On 12/03/2017 12:05 PM, bitwise wrote: > I've finally started learning git git is one of those things where as soon as you understand how it works, you lose the ability to teach. :) I'm watching this thread with amusement because like most online tutorials, nobody is mentioning the

Re: How to declare immutable struct outside of try catch and reference it later

2017-12-04 Thread kdevel via Digitalmars-d-learn
On Sunday, 3 December 2017 at 23:29:01 UTC, Basile B. wrote: On Sunday, 3 December 2017 at 22:33:40 UTC, kdevel wrote: On Sunday, 3 December 2017 at 14:58:03 UTC, Basile B. wrote: In this case i'd go for a typed pointer, e.g --- immutable struct Configuration { this(string){/*load some

Re: Passing Function as an argument to another Function

2017-12-04 Thread kdevel via Digitalmars-d-learn
On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote: On Monday, 4 December 2017 at 10:46:03 UTC, rikki cattermole wrote: FunTest.d(52): Error: template FunTest.ptProcessFiles cannot deduce function from argument types !()(string, Array!(Tuple!(string, string)) function(string FFs, string

Re: git workflow for D

2017-12-04 Thread Ali Çehreli via Digitalmars-d-learn
On 12/04/2017 09:38 AM, Patrick Schluter wrote: > So, avoid pull, look first what fetch does and if that is what you > thought it would do, do the merge and be happy. +1 Paraphrasing someone I trust very much, "Never 'pull', always 'fetch -p' and then rebase." Ali

Re: Object oriented programming and interfaces

2017-12-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-04 21:43, 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 {...} }

Re: Using enum types

2017-12-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 4 December 2017 at 22:34:41 UTC, helxi wrote: enum Waves { Sin = Wave(Positivity.Positive), Cos = Wave(Positivity.Negative) } writeln(nth_value!(Waves.Sin)(1)); } Sin and Cos there are actually values, not types...

Using enum types

2017-12-04 Thread helxi via Digitalmars-d-learn
Why can't enums be used as types in this (simplified) example? enum Positivity { Positive, Negative } struct Wave { public: Positivity slope; } enum Waves { Sin = Wave(Positivity.Positive), Cos = Wave(Positivity.Negative) } int nth_value(T : Waves)(int

SHould this work ?

2017-12-04 Thread Basile B. via Digitalmars-d-learn
void main() { import std.algorithm.iteration, std.typecons, std.stdio; [tuple(dchar(0), uint(0))].reduce!((a,b) => a[1]+b[1])(tuple(dchar(0), uint(0))).writeln; }

Re: Using enum types

2017-12-04 Thread Meta via Digitalmars-d-learn
On Monday, 4 December 2017 at 22:34:41 UTC, helxi wrote: Why can't enums be used as types in this (simplified) example? enum Positivity { Positive, Negative } struct Wave { public: Positivity slope; } enum Waves { Sin = Wave(Positivity.Positive), Cos =

Re: Passing Function as an argument to another Function

2017-12-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 04, 2017 20:02:30 kdevel via Digitalmars-d-learn wrote: > On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote: > > On Monday, 4 December 2017 at 10:46:03 UTC, rikki cattermole > > wrote: > > > > FunTest.d(52): Error: template FunTest.ptProcessFiles cannot > > deduce function

Re: git workflow for D

2017-12-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 04, 2017 12:02:37 Ali Çehreli via Digitalmars-d-learn wrote: > On 12/04/2017 09:38 AM, Patrick Schluter wrote: > > So, avoid pull, look first what fetch does and if that is what you > > thought it would do, do the merge and be happy. > > +1 > > Paraphrasing someone I trust

Re: git workflow for D

2017-12-04 Thread Eugene Wissner via Digitalmars-d-learn
On Monday, 4 December 2017 at 20:14:15 UTC, Ali Çehreli wrote: 6) 'git push -force' so that your GitHub repo is up-to-date right? (There, I mentioned "force". :) ) The right option name is --force-with-lease ).

Re: Object oriented programming and interfaces

2017-12-04 Thread Dirk via Digitalmars-d-learn
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). My goal is to write a module for a k-medoids clustering algorithm. The class MedoidClassification shall be able to partition a list of objects

Re: git workflow for D

2017-12-04 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 4 December 2017 at 11:51:42 UTC, Nick Sabalausky (Abscissa) wrote: On 12/03/2017 03:05 PM, bitwise wrote: One thing to keep in mind: Any time you're talking about moving anything from one repo to another, there's exactly two basic primitives there: push and pull. Both of them are

Re: Shared and race conditions

2017-12-04 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 16:13:13 UTC, Wanderer wrote: static void getId(shared IdGen!(MyId)* g) { writeln("next: ", g.next()); writeln("next: ", g.next()); } writeln synchronizes on stdout, so your code is mostly serialized, good example of a very subtle race condition.

Passing Function as an argument to another Function

2017-12-04 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on the below code, I want to send the name of the function ( First and Second) from main as an argument to another function(Mid) and the function "Mid" has to execute the function(First and Second). Program: import std.stdio; void First (string Ftext) {

Re: Passing Function as an argument to another Function

2017-12-04 Thread rikki cattermole via Digitalmars-d-learn
On 04/12/2017 8:22 AM, Vino wrote: Hi All,   Request your help on the below code, I want to send the name of the function ( First and Second) from main as an argument to another function(Mid) and the function "Mid" has to execute the function(First and Second). Program: import std.stdio;

Re: git workflow for D

2017-12-04 Thread crimaniak via Digitalmars-d-learn
On Sunday, 3 December 2017 at 20:05:47 UTC, bitwise wrote: How does one keep their fork up to date? For example, if I fork https://help.github.com/articles/syncing-a-fork/

Re: Passing Function as an argument to another Function

2017-12-04 Thread Vino via Digitalmars-d-learn
On Monday, 4 December 2017 at 08:27:10 UTC, rikki cattermole wrote: On 04/12/2017 8:22 AM, Vino wrote: Hi All,   Request your help on the below code, I want to send the name of the function ( First and Second) from main as an argument to another function(Mid) and the function "Mid" has to

Re: Passing Function as an argument to another Function

2017-12-04 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 4 December 2017 at 08:27:10 UTC, rikki cattermole wrote: On 04/12/2017 8:22 AM, Vino wrote: Hi All,   Request your help on the below code, I want to send the name of the function ( First and Second) from main as an argument to another function(Mid) and the function "Mid" has to

Re: git workflow for D

2017-12-04 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
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 whether you use git, subversion, or whatever), are VERY helpful on single-person projects, too! Highly

Re: Passing Function as an argument to another Function

2017-12-04 Thread rikki cattermole via Digitalmars-d-learn
On 04/12/2017 10:36 AM, Vino wrote: Hi Rikki,   Thank you very much, I tired the above code and it is working, so another help on the same topic. IF my function (First) of below type when who do we define the Mid function Array!(Tuple!(string, string))  First(string Ftext) Tried the below 

Re: git workflow for D

2017-12-04 Thread Basile B. via Digitalmars-d-learn
On Monday, 4 December 2017 at 04:45:01 UTC, Patrick Schluter wrote: On Monday, 4 December 2017 at 01:54:57 UTC, ketmar wrote: Basile B. wrote: On Sunday, 3 December 2017 at 22:22:47 UTC, Arun Chandrasekaran wrote: Git CLI is arcane and esoteric. I've lost my commits before (yeah, my

Re: Passing Function as an argument to another Function

2017-12-04 Thread Vino via Digitalmars-d-learn
On Monday, 4 December 2017 at 10:46:03 UTC, rikki cattermole wrote: On 04/12/2017 10:36 AM, Vino wrote: Hi Rikki,   Thank you very much, I tired the above code and it is working, so another help on the same topic. IF my function (First) of below type when who do we define the Mid function

Re: Passing Function as an argument to another Function

2017-12-04 Thread codephantom via Digitalmars-d-learn
On Monday, 4 December 2017 at 11:30:02 UTC, codephantom wrote: On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote: The original program is as below Error: FunTest.d(52): Error: template FunTest.ptProcessFiles cannot deduce function from argument types !()(string, Array!(Tuple!(string,

Re: Passing Function as an argument to another Function

2017-12-04 Thread Vino via Digitalmars-d-learn
On Monday, 4 December 2017 at 11:41:06 UTC, codephantom wrote: On Monday, 4 December 2017 at 11:30:02 UTC, codephantom wrote: On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote: The original program is as below Error: FunTest.d(52): Error: template FunTest.ptProcessFiles cannot deduce

Re: Passing Function as an argument to another Function

2017-12-04 Thread codephantom via Digitalmars-d-learn
On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote: The original program is as below Error: FunTest.d(52): Error: template FunTest.ptProcessFiles cannot deduce function from argument types !()(string, Array!(Tuple!(string, string)) function(string FFs, string Step, int DirAged), File,

Re: git workflow for D

2017-12-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/3/17 3:48 PM, Basile B. wrote: On Sunday, 3 December 2017 at 20:05:47 UTC, bitwise wrote: or just some specific files? and do I need a separate branch for each pull request, Yes, yes yes, again. ~master is sacrosanct. For good reason. If you commit things to your master, and they

Re: git workflow for D

2017-12-04 Thread jmh530 via Digitalmars-d-learn
On Sunday, 3 December 2017 at 20:05:47 UTC, bitwise wrote: I've finally started learning git, due to our team expanding beyond one person - awesome, right? Anyways, I've got things more or less figured out, which is nice, because being clueless about git is a big blocker for me trying to do

Re: Shared and race conditions

2017-12-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/4/17 4:09 AM, Kagamin wrote: On Wednesday, 29 November 2017 at 16:13:13 UTC, Wanderer wrote: static void getId(shared IdGen!(MyId)* g) {     writeln("next: ", g.next());     writeln("next: ", g.next()); } writeln synchronizes on stdout, so your code is mostly serialized, good example

Re: Struct inside a class: How to get outer?

2017-12-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/3/17 2:38 AM, Jonathan M Davis wrote: On Sunday, December 03, 2017 01:05:00 Nick Sabalausky via Digitalmars-d- learn wrote: Is this even possible? My attempts: class Outer { struct Inner { void foo() { // Error: no property 'outer' for type 'Inner' Outer

Re: std.range.interfaces : InputRange moveFront

2017-12-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/3/17 12:42 AM, Johan Engelen wrote: On Friday, 1 December 2017 at 18:33:09 UTC, Ali Çehreli wrote: On 12/01/2017 07:21 AM, Steven Schveighoffer wrote: > On 12/1/17 4:29 AM, Johan Engelen wrote: >> (Also, I would expect "popFront" to return the element popped, but it >> doesn't, OK... > >

Re: Mirroring a drawable buf in DLangUI?

2017-12-04 Thread Dukc via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 13:45:31 UTC, Dukc wrote: My question is, does anybody know a way to draw that image backwards without making another PNG file to do so? After a lot of code research, I believe the best way for me is to use DlangUI helpers in same way as in the new api of the

Re: Is std.container.array more or less an equivalent of C#'s List?

2017-12-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/4/17 11:26 AM, A Guy With a Question wrote: Reading this, the interface seems very similar, but I'm not sure. There's only like a two sentence general description, then it goes on to talk about a boolean specialization... https://dlang.org/phobos/std_container_array.html I'm looking

Re: Shared and race conditions

2017-12-04 Thread Kagamin via Digitalmars-d-learn
A lock on stdout works as a barrier: threads may hit it simultaneously, but pass it one by one in a queue with a time gap between them.

Re: Is std.container.array more or less an equivalent of C#'s List?

2017-12-04 Thread Basile B. via Digitalmars-d-learn
On Monday, 4 December 2017 at 16:26:02 UTC, A Guy With a Question wrote: Reading this, the interface seems very similar, but I'm not sure. There's only like a two sentence general description, then it goes on to talk about a boolean specialization...

Re: Struct inside a class: How to get outer?

2017-12-04 Thread A Guy With a Question via Digitalmars-d-learn
On Monday, 4 December 2017 at 14:01:08 UTC, Steven Schveighoffer wrote: On 12/3/17 2:38 AM, Jonathan M Davis wrote: On Sunday, December 03, 2017 01:05:00 Nick Sabalausky via Digitalmars-d- learn wrote: Is this even possible? My attempts: class Outer { struct Inner { void foo() {

Is std.container.array more or less an equivalent of C#'s List?

2017-12-04 Thread A Guy With a Question via Digitalmars-d-learn
Reading this, the interface seems very similar, but I'm not sure. There's only like a two sentence general description, then it goes on to talk about a boolean specialization... https://dlang.org/phobos/std_container_array.html I'm looking for something that doesn't have to resize every

Re: Is std.container.array more or less an equivalent of C#'s List?

2017-12-04 Thread A Guy With a Question via Digitalmars-d-learn
On Monday, 4 December 2017 at 16:26:02 UTC, A Guy With a Question wrote: Reading this, the interface seems very similar, but I'm not sure. There's only like a two sentence general description, then it goes on to talk about a boolean specialization...

Re: Shared and race conditions

2017-12-04 Thread Kagamin via Digitalmars-d-learn
Uh, a bottleneck, not a barrier.