Re: Hopefully a simple question...

2017-01-13 Thread kinke via Digitalmars-d-learn
On Friday, 13 January 2017 at 16:56:43 UTC, WhatMeWorry wrote: A vec and scalar can't be added together. So why (or how) is the glm code working? The C++ source disagrees: https://github.com/g-truc/glm/blob/master/glm/detail/type_vec2.hpp#L219 It works via operator overloading, and adding a

Re: [question] Access from UDA constructor to parent symbol

2016-12-27 Thread Jerry via Digitalmars-d-learn
On Monday, 26 December 2016 at 21:15:03 UTC, Adam D. Ruppe wrote: On Monday, 26 December 2016 at 20:07:56 UTC, crimaniak wrote: // I want to see Foo here and use it's reflection to iterate fields and methods. then pass foo to it What do you mean parent symbol? I assumed you mean

Re: [question] Access from UDA constructor to parent symbol

2016-12-27 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 27 December 2016 at 02:05:27 UTC, Ali Çehreli wrote: On 12/26/2016 02:04 PM, crimaniak wrote: So my main question: how it is possible to do such thing? Just to make sure we're on the same page: :) * There is 'interface' in addition to 'class' Yes. I want it for structs exactly

Re: [question] Access from UDA constructor to parent symbol

2016-12-26 Thread Ali Çehreli via Digitalmars-d-learn
On 12/26/2016 02:04 PM, crimaniak wrote: So my main question: how it is possible to do such thing? Just to make sure we're on the same page: :) * There is 'interface' in addition to 'class' * If all you want is to check, then you can write template constraints by following the example

Re: [question] Access from UDA constructor to parent symbol

2016-12-26 Thread crimaniak via Digitalmars-d-learn
s option I like less, and I have not researched it. So my main question: how it is possible to do such thing?

Re: [question] Access from UDA constructor to parent symbol

2016-12-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 December 2016 at 20:07:56 UTC, crimaniak wrote: // I want to see Foo here and use it's reflection to iterate fields and methods. then pass foo to it What do you mean parent symbol? I assumed you mean subclass but your example shows one class and one struct. So is

[question] Access from UDA constructor to parent symbol

2016-12-26 Thread crimaniak via Digitalmars-d-learn
``` class uda { this() { // I want to see Foo here and use it's reflection to iterate fields and methods. } } @uda struct Foo { } ``` Is there a way to do it?

Re: Question about compile-time functions.

2016-12-14 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 14 December 2016 at 07:15:08 UTC, Bauss wrote: If a function is only called during compile-time will it be available at runtime? With "available at runtime", I guess you mean "will it be part of the object file". In that case: yes. Because even if a function is _never_ called,

Re: Question about compile-time functions.

2016-12-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 14 December 2016 at 07:15:08 UTC, Bauss wrote: If a function is only called during compile-time will it be available at runtime? It depends. When linking unused functions can be removed by -gc-sections, but only when linking an executable. But obviously if you use it at

Question about compile-time functions.

2016-12-13 Thread Bauss via Digitalmars-d-learn
If a function is only called during compile-time will it be available at runtime?

Question about DUB

2016-12-11 Thread Xavier Bigand via Digitalmars-d-learn
Hi, I am using DUB with the SDL language and I have two questions: 1. How can I add some text file to my project? I want to add shaders in my Visual Project. 2. How to make a compiler option depending on the platform and debug mode at the same time? Thanks.

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Payotz via Digitalmars-d-learn
Thank you all for the replies. I'm extremely grateful. I'll look into each and every answer.

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Mike Parker via Digitalmars-d-learn
be glad for you folks to tell me what I'm missing. And for the second part of the question, I can't seem to make a Dynamic Array where I could store the delegates taken in the "registerEvent" method. Closest thing I have gotten to is this: private void delegate(T)(T args)[string] eve

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Nicholas Wilson via Digitalmars-d-learn
way I did it, so I'll be glad for you folks to tell me what I'm missing. And for the second part of the question, I can't seem to make a Dynamic Array where I could store the delegates taken in the "registerEvent" method. Closest thing I have gotten to is this: private void delega

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread crimaniak via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Ali Çehreli via Digitalmars-d-learn
way I did it, so I'll be glad > for you folks to tell me what I'm missing. All you need is your interface to these callbacks. > And for the second part of the question, I can't seem to make a Dynamic > Array where I could store the delegates taken in the "registerEvent" > method.

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread H. S. Teoh via Digitalmars-d-learn
); > > I know there's something missing in the way I did it, so I'll be glad > for you folks to tell me what I'm missing. > > And for the second part of the question, I can't seem to make a > Dynamic Array where I could store the delegates taken in the > "registerEvent&q

Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Payotz via Digitalmars-d-learn
'm missing. And for the second part of the question, I can't seem to make a Dynamic Array where I could store the delegates taken in the "registerEvent" method. Closest thing I have gotten to is this: private void delegate(T)(T args)[string] event; which resulted in the compiler screaming Error signs at

Re: Template specialization question

2016-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 24 November 2016 at 17:59:55 UTC, ag0aep6g wrote: Took me a bit to find it, but it is documented: "If both a template with a sequence parameter and a template without a sequence parameter exactly match a template instantiation, the template without a TemplateSequenceParameter

Re: Template specialization question

2016-11-24 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 24 November 2016 at 17:47:04 UTC, Steven Schveighoffer wrote: void foo(T)(T t){writeln("a");} void foo(T...)(T t){writeln("b");} foo(1); Compiles? If so, which prints out? I was surprised by the answer. I can't find docs for it. Is the behavior intended? -Steve That is

Re: Template specialization question

2016-11-24 Thread ag0aep6g via Digitalmars-d-learn
On 11/24/2016 06:47 PM, Steven Schveighoffer wrote: void foo(T)(T t){writeln("a");} void foo(T...)(T t){writeln("b");} foo(1); Compiles? If so, which prints out? I was surprised by the answer. I can't find docs for it. Is the behavior intended? Took me a bit to find it, but it is

Template specialization question

2016-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
void foo(T)(T t){writeln("a");} void foo(T...)(T t){writeln("b");} foo(1); Compiles? If so, which prints out? I was surprised by the answer. I can't find docs for it. Is the behavior intended? -Steve

Re: an extremely naive question regarding synchronized...

2016-11-16 Thread Kagamin via Digitalmars-d-learn
static MySingleton get() { if (instance_ is null) { synchronized { if (instance_ is null) { atomicStore(instance_, new MySingleton); } } } return instance_; } This should work fine and faster.

Re: an extremely naive question regarding synchronized...

2016-11-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/15/16 3:05 PM, Kapps wrote: Keep in mind, this is only slow for such a large amount of calls. If you're calling this only a hundred times a second, then who cares if it's slower. After all, with GDC we were looking at 1 billion calls in 21 seconds. That's 47,000 calls per *millisecond*.

Re: an extremely naive question regarding synchronized...

2016-11-15 Thread Kapps via Digitalmars-d-learn
On Monday, 14 November 2016 at 17:43:37 UTC, WhatMeWorry wrote: I was reading this fasciniating article: https://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/ And to quote a section of it: - static MySingleton get() {

Re: an extremely naive question regarding synchronized...

2016-11-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/14/16 12:43 PM, WhatMeWorry wrote: I was reading this fasciniating article: https://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/ And to quote a section of it: - static MySingleton get() { synchronized { if

an extremely naive question regarding synchronized...

2016-11-14 Thread WhatMeWorry via Digitalmars-d-learn
I was reading this fasciniating article: https://davesdprogramming.wordpress.com/2013/05/06/low-lock-singletons/ And to quote a section of it: - static MySingleton get() { synchronized { if (instance_ is null) { instance_ =

Re: Question on syntax

2016-11-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 9 November 2016 at 06:28:31 UTC, Jim wrote: What does it mean when a variable name starts with a '.' `.a` --> `::a`.

Re: Question on syntax

2016-11-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/11/2016 7:28 PM, Jim wrote: Hi, I'm a very experienced C++ programmer, looking at a program written in D. D is similar enough to C++ and Java that I have no problem understanding it - except for one thing. I think I may have figured it out, but I want to confirm my understanding. What

Question on syntax

2016-11-08 Thread Jim via Digitalmars-d-learn
Hi, I'm a very experienced C++ programmer, looking at a program written in D. D is similar enough to C++ and Java that I have no problem understanding it - except for one thing. I think I may have figured it out, but I want to confirm my understanding. What does it mean when a variable name

Re: Question about dsfml.system.err

2016-11-08 Thread Konstantin Kutsevalov via Digitalmars-d-learn
[] args) { err.open("errors.log", "a"); err.write("test\n"); } ... ``` but as can I see, that hasn't any effect for tcplistener module... OK ... problem with tcplistener solved, just a code mistake. But the question is actual. I can honestl

Re: Question about dsfml.system.err

2016-11-08 Thread Steven Schveighoffer via Digitalmars-d-learn
err.write("test\n"); } ... ``` but as can I see, that hasn't any effect for tcplistener module... OK ... problem with tcplistener solved, just a code mistake. But the question is actual. I can honestly say, I don't know what dsfml is or any of the code you have posted. -Steve

Re: Question about dsfml.system.err

2016-11-08 Thread Konstantin Kutsevalov via Digitalmars-d-learn
but as can I see, that hasn't any effect for tcplistener module... OK ... problem with tcplistener solved, just a code mistake. But the question is actual.

Re: Question about dsfml.system.err

2016-11-08 Thread Konstantin Kutsevalov via Digitalmars-d-learn
ADD: I tried to open other stream in main() ``` ... import dsfml.system.err; int main(string[] args) { err.open("errors.log", "a"); err.write("test\n"); } ... ``` but as can I see, that hasn't any effect for tcplistener module...

Question about dsfml.system.err

2016-11-08 Thread Konstantin Kutsevalov via Digitalmars-d-learn
I need to see errors from dsfml.system.err, but it doesn't write to terminal as I expected. The general problem is that I cannot listen any port by tcplistener. And listen method is: Status accept(TcpSocket socket) { import dsfml.system.string;

Re: A question of function design?

2016-10-28 Thread WhatMeWorry via Digitalmars-d-learn
On Friday, 28 October 2016 at 14:12:53 UTC, Mike Parker wrote: On Friday, 28 October 2016 at 13:19:19 UTC, WhatMeWorry wrote: [...] I generally use GLFW event callbacks to populate an event queue with custom event types, then process the queue and handle events elsewhere. That way, the

Re: A question of function design?

2016-10-28 Thread Mike Parker via Digitalmars-d-learn
On Friday, 28 October 2016 at 13:19:19 UTC, WhatMeWorry wrote: Anyone have a good example of what I should be doing? I generally use GLFW event callbacks to populate an event queue with custom event types, then process the queue and handle events elsewhere. That way, the callbacks need no

Re: A question of function design?

2016-10-28 Thread WhatMeWorry via Digitalmars-d-learn
On Thursday, 27 October 2016 at 22:51:13 UTC, pineapple wrote: On Thursday, 27 October 2016 at 22:17:35 UTC, WhatMeWorry wrote: I'm using Derelict GLFW3 and I found the following GLFW3 code snippet in a demo. In a small demo, crap like this usually isn't a big deal. It's not common

Re: A question of function design?

2016-10-27 Thread pineapple via Digitalmars-d-learn
On Thursday, 27 October 2016 at 22:17:35 UTC, WhatMeWorry wrote: I'm using Derelict GLFW3 and I found the following GLFW3 code snippet in a demo. In a small demo, crap like this usually isn't a big deal. It's not common practice, though, and for good reason. You should definitely avoid

A question of function design?

2016-10-27 Thread WhatMeWorry via Digitalmars-d-learn
I'm using Derelict GLFW3 and I found the following GLFW3 code snippet in a demo. float distance = 3.0; extern(C) void key_callback(GLFWwindow* window, int key, int scancode, int action, int modifier) nothrow { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) {

Re: Real Simple Question?

2016-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/22/16 5:34 PM, WhatMeWorry wrote: On Saturday, 22 October 2016 at 20:51:14 UTC, Jonathan M Davis wrote: On Saturday, October 22, 2016 20:35:27 WhatMeWorry via Digitalmars-d-learn wrote: [...] Just put it in a separate module and then import it. e.g. file: mypackage/constants.d

Re: Real Simple Question?

2016-10-25 Thread tcak via Digitalmars-d-learn
On Saturday, 22 October 2016 at 21:34:36 UTC, WhatMeWorry wrote: On Saturday, 22 October 2016 at 20:51:14 UTC, Jonathan M Davis wrote: [...] Ok, but now I'm getting these error in my new mypackage/constants.d ..\common\vertex_data.d(5,15): Error: undefined identifier 'GLfloat'

Re: Real Simple Question?

2016-10-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 22, 2016 21:34:36 WhatMeWorry via Digitalmars-d-learn wrote: > Ok, but now I'm getting these error in my new > mypackage/constants.d > > ..\common\vertex_data.d(5,15): Error: undefined identifier > 'GLfloat' > ..\common\vertex_data.d(53,12): Error: undefined identifier 'vec3'

Re: Real Simple Question?

2016-10-22 Thread WhatMeWorry via Digitalmars-d-learn
On Saturday, 22 October 2016 at 20:51:14 UTC, Jonathan M Davis wrote: On Saturday, October 22, 2016 20:35:27 WhatMeWorry via Digitalmars-d-learn wrote: [...] Just put it in a separate module and then import it. e.g. file: mypackage/constants.d == module mypackage.constants;

Re: Real Simple Question?

2016-10-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 22, 2016 20:35:27 WhatMeWorry via Digitalmars-d-learn wrote: > This is probably so simple that there's no example anywhere. > > Basically, I've got a huge array definition (see below) which I > reuse over and over again in different projects. > > GLfloat[] vertices = > [ >

Real Simple Question?

2016-10-22 Thread WhatMeWorry via Digitalmars-d-learn
This is probably so simple that there's no example anywhere. Basically, I've got a huge array definition (see below) which I reuse over and over again in different projects. GLfloat[] vertices = [ // Positions // Texture Coords -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.5f,

Re: Beginner DUB user question...

2016-10-08 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 9 October 2016 at 01:24:57 UTC, WhatMeWorry wrote: I've got a little hello_window DUB project which uses these dependencies: dependency "derelict-util" version="~>2.0.6" dependency "derelict-glfw3" version="~>3.1.0" dependency "derelict-gl3" version="~>1.0.19" dependency

Re: Beginner DUB user question...

2016-10-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/10/2016 2:24 PM, WhatMeWorry wrote: I've got a little hello_window DUB project which uses these dependencies: dependency "derelict-util" version="~>2.0.6" dependency "derelict-glfw3" version="~>3.1.0" dependency "derelict-gl3" version="~>1.0.19" dependency "derelict-fi"

Beginner DUB user question...

2016-10-08 Thread WhatMeWorry via Digitalmars-d-learn
I've got a little hello_window DUB project which uses these dependencies: dependency "derelict-util" version="~>2.0.6" dependency "derelict-glfw3" version="~>3.1.0" dependency "derelict-gl3" version="~>1.0.19" dependency "derelict-fi"version="~>2.0.3" dependency "derelict-ft"

Re: Simple Function Parameter question...

2016-10-04 Thread brian via Digitalmars-d-learn
On Tuesday, 4 October 2016 at 13:16:35 UTC, Adam D. Ruppe wrote: I'd put your repeated variables together in a struct, then pass it around to the functions. At least then you pass just one param at a time, without losing the info. That's not a bad idea. I have been creating "ids" to point to

Re: Simple Function Parameter question...

2016-10-04 Thread Adam D. Ruppe via Digitalmars-d-learn
I'd put your repeated variables together in a struct, then pass it around to the functions. At least then you pass just one param at a time, without losing the info.

Simple Function Parameter question...

2016-10-04 Thread brian via Digitalmars-d-learn
Howdy folks This might be a really stupid question, but ya know, if you don't ask ... So, anytime I am calling a function, I have to include everything that the function needs all the time. My simplistic example is: #!/usr/bin/rdmd import std.stdio; void test(string firstinput, string

Re: May be a simple dub answer if my question even makes sense?

2016-09-25 Thread WhatMeWorry via Digitalmars-d-learn
On Sunday, 25 September 2016 at 00:52:26 UTC, Mike Parker wrote: On Saturday, 24 September 2016 at 16:51:47 UTC, WhatMeWorry wrote: [...] As long as they're public. Imports are private by default, meaning their symbols are only visible locally. Change it to: module derelict_libraries;

Re: May be a simple dub answer if my question even makes sense?

2016-09-24 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 24 September 2016 at 16:51:47 UTC, WhatMeWorry wrote: My app.d has: module app; import common.derelict_libraries; and derelict_libraries.d has: module derelict_libraries; import derelict.glfw3.glfw3; import derelict.opengl3.gl3; It's fine to import other imports, Right? As

Re: May be a simple dub answer if my question even makes sense?

2016-09-24 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 24 September 2016 at 02:33:22 UTC, WhatMeWorry wrote: I see that dub has all the .d import files already placed in C:\Users\Me\AppData\Roaming\dub\packages\derelict-gl3-1.0.19\derelict-gl3\source\derelict\opengl3 and

Re: May be a simple dub answer if my question even makes sense?

2016-09-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/09/2016 2:33 PM, WhatMeWorry wrote: I have D opengl/glfw3 program that I wrote which compiles and runs fine, but I always felt it was a bit of a Visual Studio hack. So I thought I'd start anew but this time use dub from the get go. So I did dub int...etc. And put my existing code into

May be a simple dub answer if my question even makes sense?

2016-09-23 Thread WhatMeWorry via Digitalmars-d-learn
I have D opengl/glfw3 program that I wrote which compiles and runs fine, but I always felt it was a bit of a Visual Studio hack. So I thought I'd start anew but this time use dub from the get go. So I did dub int...etc. And put my existing code into the app.d file. But when I try to

Re: Question about __treats

2016-09-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/21/16 3:38 AM, Suliman wrote: On Wednesday, 21 September 2016 at 07:09:01 UTC, rikki cattermole wrote: On 21/09/2016 7:06 PM, Suliman wrote: It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't understand

Re: Question about __treats

2016-09-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/09/2016 7:38 PM, Suliman wrote: On Wednesday, 21 September 2016 at 07:09:01 UTC, rikki cattermole wrote: On 21/09/2016 7:06 PM, Suliman wrote: It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't

Re: Question about __treats

2016-09-21 Thread Suliman via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 07:09:01 UTC, rikki cattermole wrote: On 21/09/2016 7:06 PM, Suliman wrote: It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't understand difference

Re: Question about __treats

2016-09-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/09/2016 7:06 PM, Suliman wrote: It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't understand difference https://dlang.org/spec/traits.html https://dlang.org/phobos/std_traits.html Could you explain

Question about __treats

2016-09-21 Thread Suliman via Digitalmars-d-learn
It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't understand difference https://dlang.org/spec/traits.html https://dlang.org/phobos/std_traits.html Could you explain the difference?

Re: DerelictGL3.reload with specified path question.

2016-08-17 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 18 August 2016 at 03:54:24 UTC, WhatMeWorry wrote: When I saw the .dll in OpenGL.dll, I immediately thought: just Windows. But does this hold true for the linux shared opengl libraries as well? Is this why DerelictGL3.reload() does not take a path argument. But then why

Re: DerelictGL3.reload with specified path question.

2016-08-17 Thread WhatMeWorry via Digitalmars-d-learn
On Thursday, 18 August 2016 at 03:11:17 UTC, WhatMeWorry wrote: On Wednesday, 17 August 2016 at 23:21:59 UTC, Rene Zwanenburg wrote: On Wednesday, 17 August 2016 at 22:59:31 UTC, WhatMeWorry wrote: I want to store all my shared/dynamic libraries within a special directory relative to where the

Re: DerelictGL3.reload with specified path question.

2016-08-17 Thread WhatMeWorry via Digitalmars-d-learn
On Wednesday, 17 August 2016 at 23:21:59 UTC, Rene Zwanenburg wrote: On Wednesday, 17 August 2016 at 22:59:31 UTC, WhatMeWorry wrote: I want to store all my shared/dynamic libraries within a special directory relative to where the application directory is. All of the derelictXX.loads(path)

Re: DerelictGL3.reload with specified path question.

2016-08-17 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 17 August 2016 at 22:59:31 UTC, WhatMeWorry wrote: I want to store all my shared/dynamic libraries within a special directory relative to where the application directory is. All of the derelictXX.loads(path) compiles except DerelictGL3.reload(lib); which doesn't seem to be

Re: minor question of the difference between " and '

2016-08-11 Thread pineapple via Digitalmars-d-learn
On Wednesday, 10 August 2016 at 23:32:54 UTC, WhatMeWorry wrote: Afterall, isn't that the definition of a string? So what's up with the two groupings of single quotes? http://www.howtogeek.com/howto/29980/whats-the-difference-between-single-and-double-quotes-in-the-bash-shell/

Re: minor question of the difference between " and '

2016-08-10 Thread Ali Çehreli via Digitalmars-d-learn
On 08/10/2016 04:32 PM, WhatMeWorry wrote: string pwdxCommand = escapeShellCommand("pwdx", to!string(pid)); writeln("pwdxCommand = ", pwdxCommand); Output: Current process ID: 7962 pwdxCommand = 'pwdx' '7962' I'm confused as to why the writeln statement didn't output "pwdx 7962"?

minor question of the difference between " and '

2016-08-10 Thread WhatMeWorry via Digitalmars-d-learn
string pwdxCommand = escapeShellCommand("pwdx", to!string(pid)); writeln("pwdxCommand = ", pwdxCommand); Output: Current process ID: 7962 pwdxCommand = 'pwdx' '7962' I'm confused as to why the writeln statement didn't output "pwdx 7962"? Afterall, isn't that the definition of a

Re: Question regarding Base64 decoding

2016-08-08 Thread Johannes Loher via Digitalmars-d-learn
Am 02.08.2016 um 00:47 schrieb Seb: > On Monday, 1 August 2016 at 08:53:30 UTC, Kagamin wrote: >> A bug. > > ... which should be filled at Bugzilla and/or fixed. Thanks! :) I created a pullrequest: https://github.com/dlang/phobos/pull/4720

Re: Question regarding Base64 decoding

2016-08-01 Thread Seb via Digitalmars-d-learn
On Monday, 1 August 2016 at 08:53:30 UTC, Kagamin wrote: A bug. ... which should be filled at Bugzilla and/or fixed. Thanks! :)

Re: Question regarding Base64 decoding

2016-08-01 Thread Kagamin via Digitalmars-d-learn
A bug.

Question regarding Base64 decoding

2016-07-31 Thread Johannes Loher via Digitalmars-d-learn
byte buffer to the decode function. But the decodeLength function returns 33 for the encoded data, so when calling decode with a 32 byte buffer, the in contract fails. The funny thing is, when using a release build (and thus removing all contracts) everything works as expected. So my question

Re: Question about destructor of database and multiple use access

2016-07-29 Thread Suliman via Digitalmars-d-learn
So my last variant is right? How can I inspect code, to better understand how GC works? Also where I can find idiomatic code with comments? Just to read for better understand design solutions.

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Kagamin via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:24:22 UTC, Dechcaudron wrote: Also, I'm assuming what I said about calling destroy(instance) is as correct as calling a cleanup method? Class destructor also automatically calls destructors of struct members of the class.

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:24:22 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 15:18:24 UTC, Lodovico Giaretta wrote: 3) at program end, live objects are not scheduled for finalization; 4) at program end, pending finalizations from previous collections may not be run. I didn't

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:02:58 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 14:43:32 UTC, Lodovico Giaretta wrote: No! Never run important finalization in a class destructor! The GC is not obliged to run the destructors, so you may end up with your objects destroyed but the

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:18:24 UTC, Lodovico Giaretta wrote: 3) at program end, live objects are not scheduled for finalization; 4) at program end, pending finalizations from previous collections may not be run. I didn't know these two, can I get source on them? Also, I'm assuming

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:24:16 UTC, Suliman wrote: void dbInsert(string login, string uploading_date, string geometry_type, string data) { Statement stmt = conn.createStatement(); //stmt.executeUpdate("..."); // some processing of

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:43:32 UTC, Lodovico Giaretta wrote: No! Never run important finalization in a class destructor! The GC is not obliged to run the destructors, so you may end up with your objects destroyed but the connections still open. For this kind of important things, you

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:33:26 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 14:01:45 UTC, Suliman wrote: 2. Should I call destructor and how it's should like? You certainly want to close the connection to the db. Basically, the destructor is intended to free resources such as

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
I don't know anything about the driver you are using, but from my general experience with DBs I'll try to give you some insight. On Thursday, 28 July 2016 at 14:01:45 UTC, Suliman wrote: 1. Should declaration of them be field of class? I'd say so. If you intend to use each instance of the

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Suliman via Digitalmars-d-learn
class GDB { Config config; MySQLDriver driver; DataSource ds; Connection conn; this(Config config) { this.config = config; driver = new MySQLDriver(); string[string] params; string url =

Question about destructor of database and multiple use access

2016-07-28 Thread Suliman via Digitalmars-d-learn
I have for next queston. For example I have class for working with DB (I am using ddbc driver). I put some variables as class fields, and init them in constructor: class GDB { Statement stmt; Config config; MySQLDriver driver; DataSource ds;

Re: question about conditional operator (?:)

2016-07-26 Thread Ali Çehreli via Digitalmars-d-learn
On 07/26/2016 06:41 AM, Richard wrote: From http://wiki.dlang.org/Operator_precedence In case it's useful to others, I explain that table a little bit here (associativity, unordered operators, and the precedence of =>): http://ddili.org/ders/d.en/operator_precedence.html Ali

Re: question about conditional operator (?:)

2016-07-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, July 26, 2016 13:41:39 Richard via Digitalmars-d-learn wrote: > On Tuesday, 26 July 2016 at 13:19:54 UTC, ag0aep6g wrote: > > Operator precedence is different from what you think. `a ? b : > > c = d` means `(a ? b : c) = d`. But you want `a ? b : (c = d)`. > > So you need parentheses

Re: question about conditional operator (?:)

2016-07-26 Thread Richard via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 13:19:54 UTC, ag0aep6g wrote: Operator precedence is different from what you think. `a ? b : c = d` means `(a ? b : c) = d`. But you want `a ? b : (c = d)`. So you need parentheses around `p+=1`. Or just go with `if` and `else`. It's clearer anyway. From

Re: question about conditional operator (?:)

2016-07-26 Thread ag0aep6g via Digitalmars-d-learn
On 07/26/2016 03:09 PM, Richard wrote: if(n%p==0) n/=p; else p+=1; [...] However, if I replace the content of the for loop with the ?: operator, the program is not correct anymore (largestPrimeFactor(4) now returns 3): [...] n%p==0 ? n/=p :

Re: question about conditional operator (?:)

2016-07-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 13:17:27 UTC, Adam D. Ruppe wrote: (n%p==0) ? n/=p : p+=1 ; And actually, using ?: with /= and += is kinda bizarre. I think you are better off leaving this as if/else since the point of this is the assignment rather than the return value.

Re: question about conditional operator (?:)

2016-07-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 13:09:28 UTC, Richard wrote: n%p==0 ? n/=p : p+=1 ; Try (n%p==0) ? n/=p : p+=1 ; I'm pretty sure the order of operations (precedence rules) puts ?: above ==.

Re: question about conditional operator (?:)

2016-07-26 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 13:09:28 UTC, Richard wrote: Hello all, try using some parentheses: (n%p==0) ? (n/=p) : (p+=1) ;

question about conditional operator (?:)

2016-07-26 Thread Richard via Digitalmars-d-learn
Hello all, I've got a program that correctly computes the largest factor in the prime decomposition of a positive number: * import std.math std.stdio; ulong largestPrimeFactor(ulong n) { for(ulong p=2; p<=sqrt(cast(real)n); ) {

Re: Assert question

2016-07-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 12:13:02 UTC, DLearner wrote: What is the recommended way of identifying which assert has been triggered? If you compile with -g, run the program in a debugger. It will tell you. If you compile and do NOT use -release, the error message automatically printed by

Re: Assert question

2016-07-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/26/16 8:13 AM, DLearner wrote: Suppose a program contains several points that control should not get to. So each such point is blocked by assert(0). What is the recommended way of identifying which assert has been triggered? Is one allowed anything like 'assert(0,"Crashed at point A");',

Assert question

2016-07-26 Thread DLearner via Digitalmars-d-learn
Suppose a program contains several points that control should not get to. So each such point is blocked by assert(0). What is the recommended way of identifying which assert has been triggered? Is one allowed anything like 'assert(0,"Crashed at point A");', where the message goes to stderr?

Re: Probably a real simple compile-time reflection question?

2016-07-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 9 July 2016 at 21:12:24 UTC, WhatMeWorry wrote: foreach( i, str; myClassMembers) What are you doing to get myClassMembers? If it is __traits(allMembers), it just gives you the *names* of the members. To get the actual thing, you then do __traits(getMember, object, str) and can

Probably a real simple compile-time reflection question?

2016-07-09 Thread WhatMeWorry via Digitalmars-d-learn
class C { this(){ _i = 0; _j = 0; } void setVar(int i) { _i = i; } int getVar() { return _i; } int _i; int _j; } writeln("C"); foreach( i, str; myClassMembers) { writeln("member ", i, " = ", str); TypeInfo ti = typeid(str); writeln("type id is ", ti);

Re: Basic question about stderr

2016-05-21 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 21 May 2016 at 22:11:30 UTC, chaseratx wrote: On Saturday, 21 May 2016 at 22:08:15 UTC, Era Scarecrow wrote: On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote: On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote: Thanks Era, but I am not trying to fix the range

Re: Basic question about stderr

2016-05-21 Thread chaseratx via Digitalmars-d-learn
On Saturday, 21 May 2016 at 22:08:15 UTC, Era Scarecrow wrote: On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote: On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote: Thanks Era, but I am not trying to fix the range error. That was put there intentionally to create stderr

Re: Basic question about stderr

2016-05-21 Thread chaseratx via Digitalmars-d-learn
On Saturday, 21 May 2016 at 21:54:43 UTC, Era Scarecrow wrote: On Saturday, 21 May 2016 at 21:47:20 UTC, chaseratx wrote: Thanks Era, but I am not trying to fix the range error. That was put there intentionally to create stderr output. I'm trying to figure out how to get ALL stderr output

<    3   4   5   6   7   8   9   10   11   12   >