Re: ini library in OSX

2014-12-20 Thread Joel via Digitalmars-d-learn
On Monday, 13 October 2014 at 16:06:42 UTC, Robert burner Schadek 
wrote:

On Saturday, 11 October 2014 at 22:38:20 UTC, Joel wrote:
On Thursday, 11 September 2014 at 10:49:48 UTC, Robert burner 
Schadek wrote:

some self promo:

http://code.dlang.org/packages/inifiled


I would like an example?


go to the link and scroll down a page


How do you use it with current ini files ([label] key=name)?


Re: DUB build questions

2014-12-20 Thread Russel Winder via Digitalmars-d-learn

On Sat, 2014-12-20 at 05:46 +, Dicebot via Digitalmars-d-learn wrote:
 On Saturday, 20 December 2014 at 04:15:00 UTC, Rikki Cattermole 
 wrote:
   b) Can I do parallel builds with dub. CMake gives me Makefiles 
   so I can
   make -j does dub have a similar option?
  
  No
 
 Worth noting that it is not actually a dub problem as much, it is 
 simply not worth adding parallel builds because separate
 compilation is much much slower with existing D front-end 
 implementation and even doing it in parallel is sub-optimal
 compared to dump-it-all-at-once.

From previous rounds of this sort of question (for the SCons D 
tooling), the consensus of the community appeared to be that the only 
time separate module compilation was really useful was for mixed D, C, 
C++, Fortran systems. For pure D systems, single call of the compiler 
is deemed far better than traditional C, C++, Fortran compilation 
strategy. This means the whole make -j thing is not an issue, it 
just means that Dub is only really dealing with the all D situation.

The corollary to this is that DMD, LDC and GDC really need to make use 
of all parallelism they can, which I suspect is more or less none.

Chapel has also gone the compile all modules with a single compiler 
call strategy as this enables global optimization from source to 
executable.
  
-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder



Re: Derelict SDL2 library not loading on OS X

2014-12-20 Thread Mike Parker via Digitalmars-d-learn

On 12/20/2014 11:46 AM, Joel wrote:


To uninstall SDL, do I just wipe the framework, and SDL dylib?


Sorry, I can't help you there. I have no idea how things are done on 
Mac. And I think it depends on how it got there in the first place. You 
may want to take that question to the SDL mailing list (web interface at 
[1]) if no one answers here.


[1] https://forums.libsdl.org/


Re: Get vars in current scope at compile time?

2014-12-20 Thread bearophile via Digitalmars-d-learn

Rikki Cattermole:


No way to do this.


But perhaps it's worth supporting as future enhancement with a 
__traits.


What are the use cases?

Bye,
bearophile


Re: Get vars in current scope at compile time?

2014-12-20 Thread Rikki Cattermole via Digitalmars-d-learn

On 20/12/2014 11:03 p.m., bearophile wrote:

Rikki Cattermole:


No way to do this.


But perhaps it's worth supporting as future enhancement with a __traits.

What are the use cases?

Bye,
bearophile


Short answer, I'm not keen on the idea, at least not yet.
I would far more comfortable once I've categorized the different types 
of CTFE implements there can be. Since nobody has really done this before.


What makes me more uncomfortable to is DIP50. Looking over it again, 
this is getting rather close to macro systems in LISP family of language 
who do have full AST access/modification capabilities. So in other 
words, its just asking for trouble without some proper thought.


Long answer, lets consider this code:

void myfunc() {
int x, y, z;
myvalues();
}

void myvalues(string file = __FILE__, string func = __FUNCTION__, int 
line = __LINE__)() {
	__traits(functionValues, file, func, line, z) = 
__traits(functionValues, file, func, line, x) + 
__traits(functionValues, file, func, line, y)

}

This was meant to be a little off from what was asked. Because I know 
this will be wanted eventually.

Its nasty ambiguous code.
A better way might be to pass in a super function state e.g.

void myvalues(SSTATET)(SSTATET SSTATE = __SUPERSTATE__) {
with(SSTATE) {
z = x + y;
}
}

Same idea, but could be used for e.g.  mixin templates and what have you.
Want all members of SSTATE? __traits(allMembers to the rescue!

Either way, not really D.learn material.


Re: Unittest in a windows app

2014-12-20 Thread Dan Nestor via Digitalmars-d-learn
I managed to isolate the problem to the following. Program 1 
below works (displays unit test failure when run), while program 
2 does not.


* Program 1 *

import std.stdio;

unittest
{
assert(false);
}

void main()
{
writeln(Hello D-World!);
}

* Program 2 *

module winmain;

import core.sys.windows.windows;

unittest {
assert(false);
}

extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nCmdShow)
{
return 0;
}


Re: Unittest in a windows app

2014-12-20 Thread Dicebot via Digitalmars-d-learn
Can it be because Windows main wrapper consumes exceptions or 
spawn a separate thread for that or something like that?


On inheritance and polymorphism in cats and dogs (and other beasts too)

2014-12-20 Thread Derix via Digitalmars-d-learn

So, I have this pet project where classes Cat and Dog inherit
from the more generic Beast class.

All beasts prosper and multiply and so do cats and dogs. The
breeding routine is fairly constant across species, with minor
variations. So I'd like to define the breed method in the Beast
class and overload it in the Cat and Dog classes.

Something like :

Cat rita = new Cat(female);
Cat ringo= new Cat(male);
Cat junior=rita.breed(ringo);

with

Class Cat:Beast{
...
Cat breed(Cat sire){
// do what all beasts do

//then add cat-specific genetics
}
...
}   

Now, what I can't seem to figure out is the // do what all beast
do part. this current object is obviously an instance of the
Cat class. How do I de-specialize it so it can behave as an
instance of the more generic Beast class ? Then, the offspring
will in turn be an instance of Beast : how to cast it as a Cat ?

So far, all I've been able to do is to dance around the issue by
writting ad-hoc constructors like

Beast b=new Beast( someCat )

or

Cat c=new Cat(someBeast)

but this seems awkward and inefficient.

There must be some more clever and straightforward way to do
this, surely ?

Also : D is not my first OO language, but polymorphism and
inheritance still are advanced concepts for me.


Re: On inheritance and polymorphism in cats and dogs (and other beasts too)

2014-12-20 Thread tcak via Digitalmars-d-learn

On Saturday, 20 December 2014 at 15:40:32 UTC, Derix wrote:

So, I have this pet project where classes Cat and Dog inherit
from the more generic Beast class.

All beasts prosper and multiply and so do cats and dogs. The
breeding routine is fairly constant across species, with minor
variations. So I'd like to define the breed method in the 
Beast

class and overload it in the Cat and Dog classes.

Something like :

Cat rita = new Cat(female);
Cat ringo= new Cat(male);
Cat junior=rita.breed(ringo);

with

Class Cat:Beast{
...
Cat breed(Cat sire){
// do what all beasts do

//then add cat-specific genetics
}
...
}   

Now, what I can't seem to figure out is the // do what all 
beast

do part. this current object is obviously an instance of the
Cat class. How do I de-specialize it so it can behave as an
instance of the more generic Beast class ? Then, the offspring
will in turn be an instance of Beast : how to cast it as a Cat ?

So far, all I've been able to do is to dance around the issue by
writting ad-hoc constructors like

Beast b=new Beast( someCat )

or

Cat c=new Cat(someBeast)

but this seems awkward and inefficient.

There must be some more clever and straightforward way to do
this, surely ?

Also : D is not my first OO language, but polymorphism and
inheritance still are advanced concepts for me.


What you do is to implement the breed method in Beast class, 
then override it in both Cat and Dog, but then call 
super.breed() method which belongs to Beast.


Re: On inheritance and polymorphism in cats and dogs (and other beasts too)

2014-12-20 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 20 December 2014 at 15:40:32 UTC, Derix wrote:

// do what all beasts do


You'll want to call the function in the base class, which is done 
with the super keyword in D.


I wouldn't make the super function return the new instance 
though, that can't be as easily customized. I'd separate it into 
two functions: breed and genetic mix


class Beast {
 // call this on a new zygote
 // it is protected because it doesn't make sense to mix 
genetics

 // in public
 protected void mixGenetics(Beast mother, Beast father) {
  // modify this to be a combination of generic traits
  // for example
  this.furColor = mother.furColor + father.furColor;
 }
}


Now, make the specific breed functions on the subclasses. I 
didn't put that in the interface because you typically don't want 
to substitute parents with generic beasts - cats and dogs can't 
breed together, but if there was a breed(Beast) function in the 
base class, that would be permitted. (in OO theory, this is the 
liskov substitution principle)


class Cat : Beast {
Cat breed(Cat sire) {
   Cat offspring = new Cat();
   offspring.mixGenetics(this, sire);
   return offspring;
}

   protected override void mixGenetics(Cat mother, Cat father) {
   super(mother, father); // calls the generic 
Beast.mixGenetics

   // now we can do cat-specific stuff
   this.pickiness = mother.pickiness * father.pickiness;
   }
}


Dog would look similar to cat.



However, since mixGenetics really only makes sense when making a 
new Cat, you might want to make it a constructor instead of a 
method, then follow the same pattern.



Cat class. How do I de-specialize it so it can behave as an
instance of the more generic Beast class ? Then, the offspring
will in turn be an instance of Beast : how to cast it as a Cat ?


Generally speaking, de-specialization happens automatically. The 
super keyword calls the parent class' version which takes care of 
all that.


You can cast Beasts back into Cats with cast(Cat) beast. Be sure 
to check for null - if beast is a dog, that cast will return null.



So far, all I've been able to do is to dance around the issue by
writting ad-hoc constructors like


that makes some sense, you'd just want to make sure the specific 
ones are done in specific child constructors, then call the 
parent with super()


Re: Unittest in a windows app

2014-12-20 Thread Rainer Schuetze via Digitalmars-d-learn



On 19.12.2014 22:39, Dan Nestor wrote:

Hello everybody, this is my first post on this forum.

I have a question about unit testing a Windows application. I
have slightly modified Visual D's default Windows application
stub to the following:


[...]

 try
 {
 Runtime.initialize();


Runtime.initialize() no longer calls the unittests since a few versions. 
You have to call runModuleUnitTests() explicitely, e.g.


  try
  {
  Runtime.initialize();
  if (runModuleUnittests())
result = myWinMain(hInstance, hPrevInstance, lpCmdLine,
   nCmdShow);
  Runtime.terminate();
  }...


Why call function rise exception?

2014-12-20 Thread Suliman via Digitalmars-d-learn

The problem with 31 string.

http://www.everfall.com/paste/id.php?jgsdz7mdbrnm

If I uncomment it, and server response is return 404 code I code 
at runtime throw exception with text:

Can't parse config: HTTP request returned status code 404

I thought that checkLinkCode is throw any king exception, and 
tried to wrap it's in try-catch block. But without result. So 
look like it's ok.


I can't understand in which moment and why code is throwing to 
those exception.


Re: Why call function rise exception?

2014-12-20 Thread Suliman via Digitalmars-d-learn

Oh sorry I understood where problem.


Re: dco how to specify Jpath?

2014-12-20 Thread FrankLike via Digitalmars-d-learn

On Thursday, 20 November 2014 at 10:48:17 UTC, Suliman wrote:
I am playing with dco. And it's look very helpful for tiny 
projects.


I can't understand is it's possible to add to dco.ini Jpath?
I am talking about something like:
dflags=-JD:\code\d\App1\source\

but when I am trying to compile code with dco it's can't find 
import.
I looked at source code and it's look like it's do not support 
dflags...


https://github.com/FrankLIKE/dco/tree/master/source


Ok,I will add it. Thank you.


Re: dco how to specify Jpath?

2014-12-20 Thread FrankLike via Digitalmars-d-learn

On Thursday, 20 November 2014 at 10:48:17 UTC, Suliman wrote:
I am playing with dco. And it's look very helpful for tiny 
projects.


I can't understand is it's possible to add to dco.ini Jpath?
I am talking about something like:
dflags=-JD:\code\d\App1\source\

but when I am trying to compile code with dco it's can't find 
import.
I looked at source code and it's look like it's do not support 
dflags...


https://github.com/FrankLIKE/dco/tree/master/source


-Jpath
where to look for files for ImportExpressions. This switch is 
required in order to use ImportExpressions. path is a ; separated 
list of paths. Multiple -J's can be used, and the paths are 
searched in the same order.


ImportExpression:
import ( AssignExpression )

But -Ipath
-ID:\code\d\App1\source\
It's ok.
So dco now can do it.


Re: dco how to specify Jpath?

2014-12-20 Thread FrankLike via Digitalmars-d-learn

On Thursday, 20 November 2014 at 10:48:17 UTC, Suliman wrote:
I am playing with dco. And it's look very helpful for tiny 
projects.


I can't understand is it's possible to add to dco.ini Jpath?
I am talking about something like:
dflags=-JD:\code\d\App1\source\

but when I am trying to compile code with dco it's can't find 
import.
I looked at source code and it's look like it's do not support 
dflags...


https://github.com/FrankLIKE/dco/tree/master/source


Default importPath is importPath=-I$(DMDInstallDir)windows/import
You can modify it to your source. or add your source to the end.

to do it:
importPath=-I$(DMDInstallDir)windows/import 
-ID:\code\d\App1\source\


Re: dco how to specify Jpath?

2014-12-20 Thread FrankLike via Digitalmars-d-learn

On Thursday, 20 November 2014 at 10:48:17 UTC, Suliman wrote:
I am playing with dco. And it's look very helpful for tiny 
projects.


I can't understand is it's possible to add to dco.ini Jpath?
I am talking about something like:
dflags=-JD:\code\d\App1\source\

but when I am trying to compile code with dco it's can't find 
import.
I looked at source code and it's look like it's do not support 
dflags...


https://github.com/FrankLIKE/dco/tree/master/source


In dco.ini
importPath= -I..\\source // modity it to your source