Re: Getting RefCounted to work with classes

2014-08-26 Thread uri via Digitalmars-d-learn

On Monday, 25 August 2014 at 21:14:03 UTC, Bienlein wrote:

Hello,

the code below compiles and runs fine. However, when I change 
Payload from struct to class I get compiler errors:


Error	1	Error: template instance 
std.typecons.RefCounted!(Payload, 
cast(RefCountedAutoInitialize)1) does not match template 
declaration RefCounted(T, RefCountedAutoInitialize autoInit = 
RefCountedAutoInitialize.yes) if (!is(T == 
class))	C:\Users\Nutzer\Windows Ordner\Documents\Visual Studio 
2013\Projects\RefCountedScratch\RefCountedScratch\main.d	26	


I tried many things, but nothing did it. Any help appreciated 
:-).

Thanks, Bienlein


import std.stdio;
import std.typecons;

struct Payload
{
private int num = 0;

this(int i)
{
num = i;
writefln(Payload's constructor called);
}

~this()
{
 writefln(Payload's destructor called);
}
}



int main(string[] argv)
{
alias RefCounted!(Payload, RefCountedAutoInitialize.yes) 
Data;


int bar = 12;
Data data = Data(bar);

return 0;
}


RefCounted does not work with classes. Classes are reference 
types already.



The key is in the error message ...if(!is(T == class))... 
restricts the template to non-class types only.


cheers,
uri


Re: D1: Error: duplicate union initialization for size

2014-08-26 Thread Jacob Carlborg via Digitalmars-d-learn

On 26/08/14 00:57, jicman wrote:


Ok, let's try something simpler...  Where can I find the D1 v1.076
compiler error meaning of,

Error: duplicate union initialization for size

for this line,

const Size DEFAULT_SCALE = { 5, 13 };


How does the code for Size look like?

--
/Jacob Carlborg


Re: Getting RefCounted to work with classes

2014-08-26 Thread Bienlein via Digitalmars-d-learn

On Tuesday, 26 August 2014 at 06:01:25 UTC, uri wrote:

RefCounted does not work with classes. Classes are reference 
types already.


Yep, that's the problem. I also got some suspicion, then surfed 
the Internet and found the information about it. Thanks for 
explaining the error message to me. Now it even seems obvious to 
me what it wants to say ;-).


But you can define a var inside a struct that holds a class and 
this way I got it working with my class as well thanks to 
generics in D. Woohoo!


Re: Learning D

2014-08-26 Thread eles via Digitalmars-d-learn

On Monday, 25 August 2014 at 16:46:11 UTC, Ryan wrote:

Me: Software developer for 30 years.




What IDE should I use? I'm not big fan of Eclipse, although if


If you are an Eclipse (CDT) user for C/C++, then you will find a 
very similar plugin for D, called DDT, here:


http://code.google.com/p/ddt/


Re: Learning D

2014-08-26 Thread Mike Parker via Digitalmars-d-learn

On 8/26/2014 5:37 AM, Ryan wrote:


Then I thought I'd learn dub.  Well, this is NOT going well... I did a
git clone of gtk-d, then tried to build with dub (renamed the
package.json to dub.json), and it told me Conflicting package
multi-reference I have no clue and I've tried removing package
references


Any libraries you want to use that are registered in the dub registry[1] 
(which gtk-d is) should be added to your project's dub.json as 
dependencies (see [2] for an example of using gtk-d). This will cause 
dub to download and compile the libraries for you. You never have to 
pull any of them down or compile them yourself.




I tried dub remove gtk-d --version=* but it just lists out excuses why
it can't work... no retrieval journal found for..., Untracked file
found



This command will only remove libraries that dub is managing, not 
anything you have downloaded outside of dub and compiled directly.




So then I try every variation of dub remove-local and dub
remove-path I can think of.



remove-local is the inverse of add-local, which you might use when you 
want to test a dub-enabled library that hasn't yet been added to the 
registry (such as a new but unreleased version of a registered library, 
or a library you are developing locally but haven't yet released). 
add-local tells dub to look on the local filesystem rather than through 
the dub registry for the library.


I haven't looked at add-/remove-path yet, so no comment on those.

[1] http://code.dlang.org/
[2] http://code.dlang.org/packages/gtk-d


---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com



Re: Are there any exercises/challenges for D?

2014-08-26 Thread bearophile via Digitalmars-d-learn

maik klein:


Are there any exercises/challenges for D?


Some exercises here:
http://rosettacode.org/wiki/Reports:Tasks_not_implemented_in_D

Please announce them here when you solve some of them :-)

Bye,
bearophile


Process Queue and Pool

2014-08-26 Thread Nordlöw
I'm looking for a variant of taskPool but for pids created by 
spawnProcess. The typical patterns it to create a set of 
potentially created processes in ProcessQueue together with a 
ProcessPool that automatically pops for the ProcessQueue when 
their the number of activate processes in ProcessPool has below a 
certain counter which is a member of ProcessPool. Maybe the Queue 
and the Pool should be one aggregate. The typically usage is in a 
build system that only keeps a limited number of processes 
activate at the same time.


Has anybody written such a thing?


Non-GC based List/Set/Map implementation?

2014-08-26 Thread Bienlein via Digitalmars-d-learn

Hello,

does anyone know of a List/Set/Map implementation that does not 
rely on the GC? The would be the last thing I need for D to be 
really happy with it ;-)


Thanks, Bienlein


Re: Learning D

2014-08-26 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2014-08-25 at 17:09 +, Kiith-Sa via Digitalmars-d-learn
wrote:
[…]
 I don't use an IDE, but MonoD seems to be the most recommended 
 cross-platform option. It has a wiki page here if it helps: 
 http://wiki.dlang.org/Mono-D

I just tried following the instructions at http://wiki.dlang.org/Mono-D
and for Debian Sid, it doesn't work, I cannot get a MonoD install.

Yes, Debian only has MonoDevelop 4, I downloaded MonoDevelop 5.4 from
the site http://simendsjo.me/files/abothe/

-- 
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


signature.asc
Description: This is a digitally signed message part


Re: Learning D

2014-08-26 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2014-08-25 at 18:09 +, Kiith-Sa via Digitalmars-d-learn
wrote:
[…]
 I have no experience with GtkD, but with DUB you shouldn't need 
 to mess with .lib files at all. DUB automatically downloads and 
 compiles any libraries specified with dub.json, *and* links them 
 with the compiled project.
 
 (still, it'd be better if someone with GtkD/MonoD experience 
 could clarify)

Dub happily downloads the GtkD source and builds the library, and then
builds the application. I am happy to report that creating a working
GtkD program with Dub was straightforward, It Just Worked™
-- 
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


signature.asc
Description: This is a digitally signed message part


Re: Non-GC based List/Set/Map implementation?

2014-08-26 Thread ketmar via Digitalmars-d-learn
On Tue, 26 Aug 2014 10:38:46 +
Bienlein via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:

 does anyone know of a List/Set/Map implementation that does not 
 rely on the GC? The would be the last thing I need for D to be 
 really happy with it ;-)
maybe thBase will help: https://github.com/Ingrater/thBase


signature.asc
Description: PGP signature


Re: Casting to union type?

2014-08-26 Thread via Digitalmars-d-learn

On Tuesday, 26 August 2014 at 02:33:25 UTC, cc wrote:

vec2 a = vec2(1.0, 2.0); // fine
vec2 b;
b = [3.0, 4.0]; //fine
vec2 c = [5.0, 6.0]; // cannot cast float[] to vec2


There is currently no implicit for aggregates except using `alias 
this`. But in your example, it's a construction, not an 
assignment, so you need to write an appropriate constructor 
`this(float[])` analogous to `opAssign(float[])`.


Re: Learning D

2014-08-26 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2014-08-25 at 16:46 +, Ryan via Digitalmars-d-learn wrote:
[…]
 What Widget library should I use?  I started with GTKD, but since 
 there are no tutorials does this mean nobody actually does this?  
 Should I use DWT?  What about QT?

GtkD should work for you. I would have preferred Qt for portability but
QtD doesn't work for me, I actually want to use QML, and GtkD just
worked.

I didn't bother with an IDE to start with just used Emacs and a Shell,
though I am sure VIM would do as well, Sublime Text or even Notepad
++ :-)

I created a directory with a source directory added the D source in it
and then edited a Dub specification file, ran dub and it all just
compiled to a working 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


signature.asc
Description: This is a digitally signed message part


Re: Casting to union type?

2014-08-26 Thread cc via Digitalmars-d-learn
Ahh, thanks.  Looks like encapsulating the union in a struct with 
alias this gets the job done, and removes the need for overloads. 
 Neat.


struct vec2 {
union {
struct {
float x = 0.0f;
float y = 0.0f;
}
float[2] v;
}

this(float x, float y) {
this.x = x;
this.y = y;
}
this(float[v.length] f) {
v[0..length] = f[0..length];
}
alias v this;
}


C style function pointers

2014-08-26 Thread nikki via Digitalmars-d-learn

I am trying top port this code :

float interpolate( float from, float to, float amount, float
(*easing)(float) )
{
 return from + ( to-from )*( easing( amount ) );
}

float linear_interpolation( float p )
{
 return p;
}


the float (*easing)(float)  part needs to be rewritten as
float function(float) easing as far as I know and could find
here http://dlang.org/deprecate.html#C-style function pointers.

so my code is written as:

import std.stdio;

float interpolate(float from, float to, float amount, float
function(float) easing)
{
   return from + (to - from) * (easing(amount));
}

float lineair_interpolation(float p)
{
   return p;
}

void main()
{
   writeln(interpolate(100,100,10, lineair_interpolation));
}

this errors witha : Error: function test.lineair_interpolation
(float p) is not callable using argument types (), but I don't
really know where to go from here.


Re: C style function pointers

2014-08-26 Thread via Digitalmars-d-learn

On Tuesday, 26 August 2014 at 12:26:45 UTC, nikki wrote:

void main()
{
   writeln(interpolate(100,100,10, lineair_interpolation));
}

this errors witha : Error: function test.lineair_interpolation
(float p) is not callable using argument types (), but I don't
really know where to go from here.


You need to put an `` before the function name:

writeln(interpolate(100,100,10, lineair_interpolation));


Re: C style function pointers

2014-08-26 Thread ketmar via Digitalmars-d-learn
On Tue, 26 Aug 2014 12:26:43 +
nikki via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:

 this errors witha : Error: function test.lineair_interpolation
 (float p) is not callable using argument types (), but I don't
 really know where to go from here.
you need to use '' to get function pointer. i.e.

  writeln(interpolate(100,100,10, lineair_interpolation));


signature.asc
Description: PGP signature


Re: C style function pointers

2014-08-26 Thread nikki via Digitalmars-d-learn

thanks, that worked, I need to grow a feeling for those * and 


Re: Process Queue and Pool

2014-08-26 Thread Nordlöw

On Tuesday, 26 August 2014 at 09:57:57 UTC, Nordlöw wrote:

Has anybody written such a thing?


I guess the logic of this ProcessPool should run in its own 
thread by default and be protected in the same way that taskPool. 
Of course one solution is to reuse taskPool and spawn one thread 
or fiber (when it becomes available in std.concurrency) for each 
currently active Process, right?


Re: Non-GC based List/Set/Map implementation?

2014-08-26 Thread Kiith-Sa via Digitalmars-d-learn

On Tuesday, 26 August 2014 at 10:38:47 UTC, Bienlein wrote:

Hello,

does anyone know of a List/Set/Map implementation that does not 
rely on the GC? The would be the last thing I need for D to be 
really happy with it ;-)


Thanks, Bienlein


These use the work-in-progress std.allocator and seem to be more 
maintained, although they don't seem to take advantage of DMD 
2.066 (@nogc) yet:


https://github.com/economicmodeling/containers


There is a bug for '-unittest'?

2014-08-26 Thread FrankLike via Digitalmars-d-learn

Hello,every one:
There is a unit test for a.d,it will be pass,do you think it's 
right?

or it's my error?

/// the file name is a.d
  class Math
{
/// add function
static int add(int x, int y) { return x + y; }

///
unittest
{
   // assert(add(2, 2) == 5);
assert(add(-2,0) == 0);
}
}

class Sum {
  int add(int x, int y) { return x + y; }

  unittest
  {
Sum sum = new Sum;
//assert(sum.add(-2,0) == -2);
 assert(sum.add(-2,0) == 2);
  }
}

void main()
{
}
 build.bat
dmd -unittest a.d
pause

-end

Thank you.


Re: There is a bug for '-unittest'?

2014-08-26 Thread ketmar via Digitalmars-d-learn
On Tue, 26 Aug 2014 13:38:17 +
FrankLike via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:

 dmd -unittest a.d
so? you compiled the code. but you need to run the resulting .exe to
invoke unittests.

or just use 'rdmd' instead.


signature.asc
Description: PGP signature


Re: There is a bug for '-unittest'?

2014-08-26 Thread FrankLike via Digitalmars-d-learn
On Tuesday, 26 August 2014 at 13:49:39 UTC, ketmar via 
Digitalmars-d-learn wrote:

On Tue, 26 Aug 2014 13:38:17 +
FrankLike via Digitalmars-d-learn 
digitalmars-d-learn@puremagic.com

wrote:


dmd -unittest a.d
so? you compiled the code. but you need to run the resulting 
.exe to

invoke unittests.

or just use 'rdmd' instead.


Thank you,l  use it   by d.chm.


literate programming in D

2014-08-26 Thread nikki via Digitalmars-d-learn
I've been googling without luck, is there a way to do literate 
programming in D?, similar to how it's done in Coffeescript ?


http://www.coffeescriptlove.com/2013/02/literate-coffeescript.html

basically me writing comments around code and some parser that 
creates styled documents from that (with highlighted source 
code), the current documentation system doesn't export the source 
code.


anybody done this before?


Re: literate programming in D

2014-08-26 Thread bearophile via Digitalmars-d-learn

nikki:

I've been googling without luck, is there a way to do literate 
programming in D?


D1 had built-in support for literate programming, but it was 
removed from D2 because it was regarded as not useful enough:

http://digitalmars.com/d/1.0/html.html

I find literate Haskell programs all the time:
gist.github.com/nooodl/e23337d0175ad66ea5f0

Or F# ones:
http://tomasp.net/blog/2014/puzzling-fsharp/

Bye,
bearophile


Re: Non-GC based List/Set/Map implementation?

2014-08-26 Thread Bienlein via Digitalmars-d-learn
Thanks for the replies. This looks good. I meanwhile found 
http://dsource.org/projects/dcollections But it seems to be 
GC-based just like Tango ... ;-(.


Re: literate programming in D

2014-08-26 Thread nikki via Digitalmars-d-learn
Aha, then It's quite safe to assume it won't be coming back I 
guess, then I might need to cook up some homebrew alternative.


thanks for the info


Re: Learning D

2014-08-26 Thread HeiHon via Digitalmars-d-learn

On Monday, 25 August 2014 at 16:46:11 UTC, Ryan wrote:
What IDE should I use? I'm not big fan of Eclipse, although if 
I had to use it this wouldn't be a dealbreaker.  Give me 
something easy and lightweight, unless you've got a GUI builder 
(this is why I started with MonoDevelop, though this isn't 
working so well for me).


If you can do without all bells and whistles of a fullblown IDE, 
you can try geany. I really like it and do all my D (and 
python/shell/perl) work with geany.


http://www.geany.org/

You just install dmd (or gdc or ldc) and add it to your PATH.
You download and install geany.
You configure the build/compile settings for geany eg:
rdmd --build-only --force -debug %f

And there you go.

Geany is available for Windows and Linux.


Re: literate programming in D

2014-08-26 Thread bachmeier via Digitalmars-d-learn

On Tuesday, 26 August 2014 at 14:55:08 UTC, nikki wrote:
I've been googling without luck, is there a way to do literate 
programming in D?, similar to how it's done in Coffeescript ?


http://www.coffeescriptlove.com/2013/02/literate-coffeescript.html

basically me writing comments around code and some parser that 
creates styled documents from that (with highlighted source 
code), the current documentation system doesn't export the 
source code.


anybody done this before?


Would org-mode in Emacs work for you? That's what I use.

http://orgmode.org/worg/org-contrib/babel/intro.html


Re: Is this a bug when creating proxies in classes?

2014-08-26 Thread Gary Willoughby via Digitalmars-d-learn

On Monday, 25 August 2014 at 21:14:42 UTC, Ali Çehreli wrote:

On 08/25/2014 12:17 PM, Marc Schütz schue...@gmx.net wrote:

On Monday, 25 August 2014 at 19:12:48 UTC, Marc Schütz wrote:

On Monday, 25 August 2014 at 18:44:36 UTC, Ali Çehreli wrote:
It can be explained if the mixed-in template is evaluated at 
the
mixin context without bringing in the imported modules to 
that
context. I don't know whether it is true or whether it is a 
known

limitation.


You're right, that's it! It works when I import std.traits 
first.


So... the fix is to import std.traits inside template Proxy. 
Going to

submit a PR.


https://github.com/D-Programming-Language/phobos/pull/2463


Thanks! And I learned from you in the pull request the 
following fact:


quote
Quoting http://dlang.org/template-mixin :
Unlike a template instantiation, a template mixin's body is 
evaluated within the scope where the mixin appears, not where 
the template declaration is defined. It is analogous to cutting 
and pasting the body of the template into the location of the 
mixin.

/quote

Ali


With that in mind what is strange is that if in my example you 
change the class for a struct everything works as expected. Why 
is that?


Re: literate programming in D

2014-08-26 Thread nikki via Digitalmars-d-learn

That would work very fine, thanks sir!


Re: D1: Error: duplicate union initialization for size

2014-08-26 Thread Ali Çehreli via Digitalmars-d-learn

On 08/25/2014 11:36 PM, Jacob Carlborg wrote:

On 26/08/14 00:57, jicman wrote:


Ok, let's try something simpler...  Where can I find the D1 v1.076
compiler error meaning of,

Error: duplicate union initialization for size

for this line,

const Size DEFAULT_SCALE = { 5, 13 };


How does the code for Size look like?



In case it helps you or others to answer, the code appears in D2 as well:

  https://github.com/D-Programming-Language/dmd/blob/master/src/todt.c#L908

The following bug is fixed for D2, which may be the same issue:

  https://issues.dlang.org/show_bug.cgi?id=8902

Ali



Re: Is this a bug when creating proxies in classes?

2014-08-26 Thread via Digitalmars-d-learn

On Tuesday, 26 August 2014 at 18:13:52 UTC, Gary Willoughby wrote:
With that in mind what is strange is that if in my example you 
change the class for a struct everything works as expected. Why 
is that?


This is bizarre... I tried a few things, but I have no idea. At 
first I thought the `static if` that calls `isArray` is inside 
another `static if`, but this is not the case.


Might be a compiler bug?


whats happening to my binary file size?

2014-08-26 Thread Israel via Digitalmars-d-learn

I wasnt paying any attention to the file size of my binaries when
i started using D.

My first program is simple and compiles at 486kb, which honestly,
is kind of absurd but anyways, after i start adding other imports
it ran all the way up to 4.5mb.

what i want to ask is, what exactly is happening to my binary
when all i do is import various modules?


Re: whats happening to my binary file size?

2014-08-26 Thread Messenger via Digitalmars-d-learn

On Tuesday, 26 August 2014 at 23:36:44 UTC, Israel wrote:
I wasnt paying any attention to the file size of my binaries 
when

i started using D.

My first program is simple and compiles at 486kb, which 
honestly,
is kind of absurd but anyways, after i start adding other 
imports

it ran all the way up to 4.5mb.

what i want to ask is, what exactly is happening to my binary
when all i do is import various modules?


Conjecture: your binary has its imports statically linked in, and 
your linker doesn't remove unused code (--gc-sections).


https://issues.dlang.org/show_bug.cgi?id=879


Re: whats happening to my binary file size?

2014-08-26 Thread Vladimir Panteleev via Digitalmars-d-learn

On Tuesday, 26 August 2014 at 23:36:44 UTC, Israel wrote:
I wasnt paying any attention to the file size of my binaries 
when

i started using D.

My first program is simple and compiles at 486kb, which 
honestly,
is kind of absurd but anyways, after i start adding other 
imports

it ran all the way up to 4.5mb.

what i want to ask is, what exactly is happening to my binary
when all i do is import various modules?


You can see what's taking up space by upload a .map file here:
http://thecybershadow.net/d/mapview/


Re: whats happening to my binary file size?

2014-08-26 Thread Israel via Digitalmars-d-learn

On Wednesday, 27 August 2014 at 01:41:51 UTC, Messenger wrote:

On Tuesday, 26 August 2014 at 23:36:44 UTC, Israel wrote:
I wasnt paying any attention to the file size of my binaries 
when

i started using D.

My first program is simple and compiles at 486kb, which 
honestly,
is kind of absurd but anyways, after i start adding other 
imports

it ran all the way up to 4.5mb.

what i want to ask is, what exactly is happening to my binary
when all i do is import various modules?


Conjecture: your binary has its imports statically linked in, 
and your linker doesn't remove unused code (--gc-sections).


https://issues.dlang.org/show_bug.cgi?id=879


I see, thanks man. From what i understand is that this is a
unintended feature rather than a direct bug in order to make
my life easier?

I know that object files are stored in .a libraries but all this
seems too advanced for me to understand...


Re: D1: Error: duplicate union initialization for size

2014-08-26 Thread jicman via Digitalmars-d-learn


On Tuesday, 26 August 2014 at 06:36:59 UTC, Jacob Carlborg wrote:

On 26/08/14 00:57, jicman wrote:


Ok, let's try something simpler...  Where can I find the D1 
v1.076

compiler error meaning of,

Error: duplicate union initialization for size

for this line,

const Size DEFAULT_SCALE = { 5, 13 };


How does the code for Size look like?


I wish I knew. :-(  Above, in this same post I pasted all lines 
that had Size and right below it all lines that had size.  These 
are all the places where Size is found.  If you can tell me which 
one you think it is, I can grab that piece of the code.


Tehse are all the lines where Size is found in all the dfl
library files:

clientSize = Size(340, 150);
final Size size() // getter
Size result;
Size defaultSize() // getter
return Size(75, 23);
override Size defaultSize() // getter
return Size(120, 23); // ?
final Size clientSize() // getter
final void clientSize(Size sz) // setter
//wclientsz = Size(width, height);
final void size(Size sz) // setter
final Size size() // getter
return wrect.size; // struct Size, not sizeof.
final Size getAutoScaleSize(Font f)
Size result;
final Size getAutoScaleSize()
package final Size _fetchClientSize()
return Size(r.right, r.bottom);
Size defaultSize() // getter
return Size(0, 0);
Size wclientsz;
deprecated final void autoScrollMargin(Size sz) // setter
deprecated final Size autoScrollMargin() // getter
return Size(0, 0);
deprecated final void autoScrollMinSize(Size sz) // setter
deprecated final Size autoScrollMinSize() // getter
return Size(0, 0);
final Size autoScaleBaseSize() // getter
final void autoScaleBaseSize(Size newSize) // setter
static Size calcScale(Size area, Size toScale, Size fromScale)
// package
Size calcScale(Size area, Size toScale) // package
final void _scale(Size toScale) // package
void xscale(Control c, Size fromScale)
Size sz;
sz = calcScale(Size(c.left, c.top), toScale, 
fromScale);
final void scrollSize(Size sz) // setter
final Size scrollSize() // getter
const Size DEFAULT_SCALE = { 5, 13 };
//Size scrollmargin, scrollmin;
Size autossz = DEFAULT_SCALE;
Size scrollsz = { 0, 0 };
Point opAdd(Size sz)
Point opSub(Size sz)
void opAddAssign(Size sz)
void opSubAssign(Size sz)
struct Size // docmain
/// Construct a new Size.
static Size opCall(int width, int height)
Size sz;
static Size opCall()
Size sz;
Dequ opEquals(Size sz)
Size opAdd(Size sz)
Size result;
Size opSub(Size sz)
Size result;
void opAddAssign(Size sz)
void opSubAssign(Size sz)
Size size() //getter
return Size(width, height);
void size(Size sz) // setter
static Rect opCall(Point location, Size size)
void inflate(Size insz)
Size size(); // getter
final override Size size() // getter
return Size(bm.bmWidth, bm.bmHeight);
Size sz;
Size sz;
final override Size size() // getter
Size result;
final Size getSize(HDC hdc) // package
return Size(getWidth(hdc), getHeight(hdc));
final Size getSize(Graphics g)
return Size(getWidth(g), getHeight(g));
Size sz;
final Size measureText(Dstring text, Font font)
return Size(sz.cx, sz.cy);
final Size measureText(Dstring text, Font font, int maxWidth,
TextFormat fmt)
return Size(rect.right - rect.left, rect.bottom - rect.top);
final Size measureText(Dstring text, Font font, TextFormat fmt)
final Size measureText(Dstring text, Font font, int maxWidth)
final Size measureText(Dstring text, Font font)
final Size getScaleSize(Font f)
Size result;
final Size size() // getter
return Size(_w, _h);
final override Size size() // getter
return Size(bm.bmWidth, bm.bmHeight);
protected override Size defaultSize() // getter
return Size(300, 300);
//Size csz;
final void minimumSize(Size min) // setter
Size changesz;
final Size minimumSize() // getter
final void maximumSize(Size max) // setter
Size changesz;
final Size maximumSize() // getter
Size autoscaleBase;
Size minsz, maxsz; // {0, 0} means none.
wclientsz = 

Re: 'idiomatic' porting of c and or c++ code that does NULL checking

2014-08-26 Thread Vladimir Panteleev via Digitalmars-d-learn

On Monday, 25 August 2014 at 03:19:09 UTC, Mike Parker wrote:
I use Exception for recoverable errors and Error for those that 
aren't.


Sorry, you're right, that description of Exception/Error is 
correct. But I don't think that SDL initialization is a 
non-recoverable error. The program might want to retry SDL 
initialization with different parameters, and if that code would 
make it into a library, said library might try using a different 
graphics library or use some other form of user interaction.


Re: 'idiomatic' porting of c and or c++ code that does NULL checking

2014-08-26 Thread eles via Digitalmars-d-learn

On Wednesday, 27 August 2014 at 05:45:34 UTC, eles wrote:
On Wednesday, 27 August 2014 at 05:39:59 UTC, Vladimir 
Panteleev wrote:

On Monday, 25 August 2014 at 03:19:09 UTC, Mike Parker wrote:





failure and the SIGKILL.


(and SIGKILL just because you cannot catch it, otherwise you 
could yell at the user...)


Re: 'idiomatic' porting of c and or c++ code that does NULL checking

2014-08-26 Thread eles via Digitalmars-d-learn
On Wednesday, 27 August 2014 at 05:39:59 UTC, Vladimir Panteleev 
wrote:

On Monday, 25 August 2014 at 03:19:09 UTC, Mike Parker wrote:




Sorry, you're right, that description of Exception/Error is 
correct. But I don't think that SDL initialization is a 
non-recoverable error. The program might want to retry SDL 
initialization with different parameters


While this may be true in this case, I think that, in general, 
you cannot draw such a clear line between what's recoverable and 
what's not. If you really want to push things to the extreme, the 
sole unrecoverable error shall be assertion failure and the 
SIGKILL.


Everything else could be otherwise handled, even if for that 
you'd need to program a new operating system inside your program, 
just because the one that intend to use is missing ;)


No, that's extreme. But, matter is, what is recoverable and what 
not, is a matter of what the architect (and the specification) 
decide to be.