Re: Accessing __FILE__ and __LINE__ of caller in combination with varargs?

2016-04-16 Thread WebFreak001 via Digitalmars-d-learn
On Saturday, 16 April 2016 at 00:03:59 UTC, Jonathan M Davis 
wrote:
Yes, you can do that, but do _not_ do that unless you really 
have no other choice. What you need to realize is that because 
the file and line number arguments will be unique for every 
call to this function, it will generate a new instantiation of 
it _every_ time it is called. So, you're going to get a lot of 
code bloat. There are rare cases where such bloat would be 
acceptable, but in the general case, it's a terrible thing to 
do. This particular case might be acceptable given how short it 
is, but in general, using __FILE__ or __LINE__ as template 
arguments should be avoided like the plague.


yeah I know that but there is really no other way in this case 
because of the varargs. Also because of the varargs the function 
will be different most of the time when always passing different 
arguments. There should be some "give me location of caller" 
keyword in D


Also, to nitpick your exact implementation, debug blocks and 
assertions aren't even vaguely related. debug blocks are used 
with the -debug flag with the intention of being used for 
printing out additional debug information (and getting around 
restrictions with pure with those messages while you're at it). 
They have nothing to do with -release, which is what controls 
assertions. What you really want to be doing is to use 
version(assert), not debug.


right, makes sense because there is a release with assertion 
flags.





Re: Dlang UI - making widget extend to the bounds of the window

2016-04-16 Thread stunaep via Digitalmars-d-learn

On Friday, 15 April 2016 at 10:33:35 UTC, Vadim Lopatin wrote:

On Friday, 15 April 2016 at 00:58:58 UTC, stunaep wrote:
I'm trying to make a gui program with dlangui, but no matter 
what I do, I cannot get widgets to fill the whole window. The 
window is resizable so I cannot just set the widths to static 
numbers.


No layoutWidth and layoutHeight set:
http://i.imgur.com/UySt30K.png

layoutWidth/Height set to fill (left widget width 300):
http://i.imgur.com/76tMIFz.png

I need these widgets to extend the width of the window because 
it is resizable

http://i.imgur.com/PiL7Y7f.png

You can see this also on DlangUI ML editor:
  fill:
http://i.imgur.com/t9DsASt.png

  wrap:
http://i.imgur.com/FoTS69g.png


  arbitrary number:
http://i.imgur.com/voiYTWZ.png


For parent VerticalLayout, set layoutWidth: fill too

VerticalLayout {
id: main;
layoutWidth: fill;
VerticalLayout {
layoutWidth: fill;
TextWidget { text: "test"; layoutWidth: fill }
}
}


I am doing that. I think it has to do with my high dpi because 
I'm using a 4k monitor.


If I use Modal window flag:
Window window = Platform.instance.createWindow("DlangUI OpenGL 
Example", null, WindowFlag.Modal, 800, 700);

http://i.imgur.com/FJgPq8U.png

If I use resizable:
Window window = Platform.instance.createWindow("DlangUI OpenGL 
Example", null, WindowFlag.Resizable, 800, 700);

http://i.imgur.com/PsPwoSN.jpg



Re: Dlang UI - making widget extend to the bounds of the window

2016-04-16 Thread stunaep via Digitalmars-d-learn
And no matter what window size I put when using Modal or 
Fullscreen, it always shows that same sized window


Re: Dlang UI - making widget extend to the bounds of the window

2016-04-16 Thread stunaep via Digitalmars-d-learn

On Saturday, 16 April 2016 at 08:20:33 UTC, stunaep wrote:

On Friday, 15 April 2016 at 10:33:35 UTC, Vadim Lopatin wrote:

[...]


I am doing that. I think it has to do with my high dpi because 
I'm using a 4k monitor.


If I use Modal window flag:

[...]

http://i.imgur.com/FJgPq8U.png

If I use resizable:

[...]

http://i.imgur.com/PsPwoSN.jpg


Actually, that is with the opengl area set to a specific size. 
Here is using fill:


Window window = Platform.instance.createWindow("DlangUI OpenGL 
Example", null, WindowFlag.Modal, 1250, 1250);

http://i.imgur.com/exAyjI0.png

   Window window = Platform.instance.createWindow("DlangUI 
OpenGL Example", null, WindowFlag.Resizable, 1250, 1250);

http://i.imgur.com/R7oxBa0.jpg

http://pastebin.com/qqbfQLvN


.opAssign disabled without @disable

2016-04-16 Thread denizzzka via Digitalmars-d-learn

Hi!

DMD and LDC2 complain about disabled opAssign, but I am not used 
@disable and depend package "gfm" also isn't uses @disable.


Steps to reproduce:

git clone https://github.com/denizzzka/r-tree.git
cd r-tree
git checkout 803eed22
dub test

Fetching gfm 6.0.0 (getting selected version)...
Placing gfm 6.0.0 to /home/denizzz/.dub/packages/...
Generating test runner configuration '__test__library__' for 
'library' (sourceLibrary).

Performing "unittest" build using dmd for x86_64.
gfm:math 6.0.0: building configuration "library"...
r-tree ~master: building configuration "__test__library__"...
source/package.d(109,31): Error: function 
rtree.RAMNode!(Box!(int, 2), ubyte).RAMNode.opAssign is not 
callable because it is annotated with @disable
source/package.d(110,26): Error: function 
rtree.RAMNode!(Box!(int, 2), ubyte).RAMNode.opAssign is not 
callable because it is annotated with @disable
source/package.d(330,25): Error: template instance 
rtree.RTree!(RAMNode!(Box!(int, 2), ubyte), true) error 
instantiating

dmd failed with exit code 1.

If I am try to add opAssign to struct RAMNode manually it is 
compiles. (But there is enough postblit constructor.)


Re: Accessing __FILE__ and __LINE__ of caller in combination with varargs?

2016-04-16 Thread Simen Kjaeraas via Digitalmars-d-learn
On Saturday, 16 April 2016 at 00:03:59 UTC, Jonathan M Davis 
wrote:
On Friday, April 15, 2016 20:52:42 WebFreak001 via 
Digitalmars-d-learn wrote:



void assertf(string file = __FILE__, size_t line = __LINE__,
Args...)(lazy bool condition, in string message, Args args) {


Yes, you can do that, but do _not_ do that unless you really 
have no other choice. What you need to realize is that because 
the file and line number arguments will be unique for every 
call to this function, it will generate a new instantiation of 
it _every_ time it is called. So, you're going to get a lot of 
code bloat. There are rare cases where such bloat would be 
acceptable, but in the general case, it's a terrible thing to 
do. This particular case might be acceptable given how short it 
is, but in general, using __FILE__ or __LINE__ as template 
arguments should be avoided like the plague.


A few tricks to reduce this bloat:

- Write a small wrapper. This will still give bloat, but only of
small functions:

void assertf(string file = __FILE__, size_t line = __LINE__, 
Args...)(lazy bool condition, in string message, Args args) {

assertfImpl(file, line, condition, message, args);
}

- Only care about line numbers in debug mode. Makes debug more 
bloated, code less readable, and you lose out on line numbers in 
release. Still worth it occasionally:


version (debug) {
void foo(string file = __FILE__, size_t line = __LINE__, 
Args...)(Args args) {

// Stuffs.
}
} else {
void assertf(Args...)(Args args) {
// Stuffs.
}
}

I'd love to have a way to pass the file and line number info as 
regular parameters, though. Something like:


void foo(Args...)(Args args, string file = __FILE__, int line = 
__LINE__) {}


Sadly, currently not possible. Maybe we could overload @disable 
for this purpose?


void foo(Args...)(Args args, @disable string file = __FILE__, 
@disable int line = __LINE__) {}


--
  Simen


Re: Why does Reggae use mixins?

2016-04-16 Thread Nordlöw via Digitalmars-d-learn

On Friday, 15 April 2016 at 13:18:46 UTC, Nordlöw wrote:
Why does the build system Reggae use mixins everywhere in the D 
examples?


https://github.com/atilaneves/reggae


Correction, it can do stuff either at CT or run-time as show here:

https://github.com/atilaneves/reggae/blob/master/doc/basics.md

Could somebody highlight when either is adviced?


Re: Why does Reggae use mixins?

2016-04-16 Thread Atila Neves via Digitalmars-d-learn

On Saturday, 16 April 2016 at 13:04:24 UTC, Nordlöw wrote:

On Friday, 15 April 2016 at 13:18:46 UTC, Nordlöw wrote:
Why does the build system Reggae use mixins everywhere in the 
D examples?


https://github.com/atilaneves/reggae


Correction, it can do stuff either at CT or run-time as show 
here:


https://github.com/atilaneves/reggae/blob/master/doc/basics.md

Could somebody highlight when either is adviced?


Mixins are used so a D build description can be written at 
module-scope, thereby looking like a scripting language. The only 
reason this is important is to enable builds that have run-time 
logic, which is pretty much all of the high-level rules (since 
they have to read the file system).
the build template mixin doesn't have to be used, the only thing 
reggae wants from a build description written in D is that there 
be one and exactly one function with the signature:


Build func();

That's the function that gets called to generate the build. Since 
I'm lazy I created a template mixin to write the function for me, 
which again means that all definitions can be at module-scope.

Basically it's so that the file looks like:

alias exe = executable!(...);
mixin build!(exe);

Instead of:

Build myBuild() {
auto exe = executable(...);
return Build(exe);
}


Atila


Which application is much suited and which is not.

2016-04-16 Thread newBeeee via Digitalmars-d-learn
Let's say you have decided to use D programming language. For 
what kind of applications would you choose D programming language 
and For what kind of applications you won't choose D programming.





Re: .opAssign disabled without @disable

2016-04-16 Thread denizzzka via Digitalmars-d-learn

On Saturday, 16 April 2016 at 11:48:56 UTC, denizzzka wrote:

source/package.d(109,31): Error: function 
rtree.RAMNode!(Box!(int, 2), ubyte).RAMNode.opAssign is not 
callable because it is annotated with @disable
source/package.d(110,26): Error: function 
rtree.RAMNode!(Box!(int, 2), ubyte).RAMNode.opAssign is not 
callable because it is annotated with @disable
source/package.d(330,25): Error: template instance 
rtree.RTree!(RAMNode!(Box!(int, 2), ubyte), true) error 
instantiating


Perhaps I should explain that struct RAMNode placed in repository 
above. (And it isn't contains any @disable)




Re: .opAssign disabled without @disable

2016-04-16 Thread Alex Parrill via Digitalmars-d-learn

On Saturday, 16 April 2016 at 11:48:56 UTC, denizzzka wrote:

Hi!

DMD and LDC2 complain about disabled opAssign, but I am not 
used @disable and depend package "gfm" also isn't uses @disable.


...


Try removing the const from this line:

debug private const bool isLeafNode = false;

I suspect that D is disabling whole-structure assignment since 
allowing it would mean that the constant `isLeafNode` could be 
changed.


Re: .opAssign disabled without @disable

2016-04-16 Thread denizzzka via Digitalmars-d-learn

On Saturday, 16 April 2016 at 15:15:18 UTC, Alex Parrill wrote:


Try removing the const from this line:

debug private const bool isLeafNode = false;

I suspect that D is disabling whole-structure assignment since 
allowing it would mean that the constant `isLeafNode` could be 
changed.


Tried - is no avail.


Re: Which application is much suited and which is not.

2016-04-16 Thread Adam D. Ruppe via Digitalmars-d-learn
I use D for everything unless I cannot by some exterior 
constraint.


Re: Which application is much suited and which is not.

2016-04-16 Thread Bauss via Digitalmars-d-learn

On Saturday, 16 April 2016 at 14:08:05 UTC, newB wrote:
Let's say you have decided to use D programming language. For 
what kind of applications would you choose D programming 
language and For what kind of applications you won't choose D 
programming.


I use D for pretty much everything. I use for a new website I'm 
working on using D and my own custom template engine for 
rendering websites similar to asp.net,'s mvc and razor. I use it 
for most applications I do, small or big. The only time I don't 
use D is when I'm at work since I work with a lot of already 
existing .net code but I'd never start a new project not written 
in D. The reason is pretty simply; D had everything that could 
ever need and things it lacks has never been things I couldn't do 
myself. By using D I have achieved and accomplished things much 
faster than any other languages that I use/used and it's been 
performing better too. I haven't had a reason not to use D yet.


Re: Which application is much suited and which is not.

2016-04-16 Thread Eugene Wissner via Digitalmars-d-learn

On Saturday, 16 April 2016 at 14:08:05 UTC, newB wrote:
Let's say you have decided to use D programming language. For 
what kind of applications would you choose D programming 
language and For what kind of applications you won't choose D 
programming.


I would use D for web programming and for desktop applications, 
system programs. Though D website says, D can be used for 
scripting, I would never choose D for scripting. Programs that 
relies on a lot of system programs or that should call other 
shell scripts, I would write in bash.


Using -J with dub

2016-04-16 Thread Bauss via Digitalmars-d-learn
Is there a way to achieve using -J through dub, preferable 
through dub.json


I can't seem to find anything through the dub.json docs on how to 
pass regular dmd flags.


Re: Using -J with dub

2016-04-16 Thread Zekereth via Digitalmars-d-learn

On Saturday, 16 April 2016 at 20:57:10 UTC, Bauss wrote:
Is there a way to achieve using -J through dub, preferable 
through dub.json


I can't seem to find anything through the dub.json docs on how 
to pass regular dmd flags.


For just -J option use stringImportPaths "". For other 
commands use the dflags option.


Re: Using -J with dub

2016-04-16 Thread Bauss via Digitalmars-d-learn

On Saturday, 16 April 2016 at 23:46:58 UTC, Zekereth wrote:

On Saturday, 16 April 2016 at 20:57:10 UTC, Bauss wrote:
Is there a way to achieve using -J through dub, preferable 
through dub.json


I can't seem to find anything through the dub.json docs on how 
to pass regular dmd flags.


For just -J option use stringImportPaths "". For other 
commands use the dflags option.


Thank you


Re: .opAssign disabled without @disable

2016-04-16 Thread denizzzka via Digitalmars-d-learn

Tried to build small test app - is not reproduced.