Re: Blog Post #0099: A Special Request

2020-01-21 Thread Antonio Corbi via Digitalmars-d-learn

On Tuesday, 21 January 2020 at 22:06:30 UTC, Ron Tarrant wrote:

On Tuesday, 21 January 2020 at 18:57:47 UTC, Jan Hönig wrote:

I would also like to request a future blog post about 
animation.
I know you have done that in the past, but i am thinking of 
some animation triggered by user input (say a button, or some 
text field, which provides parameters for a circle).


Just to make sure I know exactly what you want...

- the user inputs parameters for a circle - I'm assuming size, 
position, perhaps the fraction of the circle (half, quarter, 
two-thirds, whatever)

- the user then clicks a button and that draws the circle.

Is that more or less what you're after?


Hi Ron!

Do you still have the Maurer Rose example? Do you think it could 
fit this kind of example?


Antonio


Re: Blog Post #0099: A Special Request

2020-01-21 Thread Ron Tarrant via Digitalmars-d-learn

On Tuesday, 21 January 2020 at 18:57:47 UTC, Jan Hönig wrote:


I would also like to request a future blog post about animation.
I know you have done that in the past, but i am thinking of 
some animation triggered by user input (say a button, or some 
text field, which provides parameters for a circle).


Just to make sure I know exactly what you want...

- the user inputs parameters for a circle - I'm assuming size, 
position, perhaps the fraction of the circle (half, quarter, 
two-thirds, whatever)

- the user then clicks a button and that draws the circle.

Is that more or less what you're after?



Re: CTFE and assoc array

2020-01-21 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jan 21, 2020 at 04:51:35PM -0500, Steven Schveighoffer via 
Digitalmars-d-learn wrote:
[...]
> It would be really cool to make AA's at CTFE change into runtime AAs
> when used at runtime, and be accessible as compile-time AAs otherwise.
[...]

I've been wishing for this since the early days when I first joined D.


T

-- 
Маленькие детки - маленькие бедки.


Re: Blog Post #0099: A Special Request

2020-01-21 Thread Ron Tarrant via Digitalmars-d-learn

On Tuesday, 21 January 2020 at 18:57:47 UTC, Jan Hönig wrote:
Hi Ron. Your blog is great. I have saved it for the future. (I 
know it from reddit).

Glad you like it.


I would also like to request a future blog post about animation.
I know you have done that in the past, but i am thinking of 
some animation triggered by user input (say a button, or some 
text field, which provides parameters for a circle).


Okay. I'll see what I can come up with. Lead time is 2-3 months, 
just so you're aware.


Re: CTFE and assoc array

2020-01-21 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/19/20 8:02 AM, Andrey wrote:

On Saturday, 18 January 2020 at 21:44:35 UTC, Boris Carvajal wrote:


I read that thread. But:
Deprecation: initialization of immutable variable from static this is 
deprecated.

Use shared static this instead.


That should have been noted in the original thread. shared static this 
is required to initialize static immutables. Simple reason -- a static 
immutable is shared between all threads, so you shouldn't be 
initializing shared static data in every thread that gets created.



And we get? No CTFE with static immutable AA?


Right, CFTE cannot access static immutable AA that are initialized at 
runtime.


But you can access the enum.

e.g. (yes it's horrid):

enum sorted = Qwezzz.qazMap.keys.sort();

It would be really cool to make AA's at CTFE change into runtime AAs 
when used at runtime, and be accessible as compile-time AAs otherwise.


-Steve


Re: `This` reference not accessible when overloading an operator?

2020-01-21 Thread Mathias Lang via Digitalmars-d-learn

On Tuesday, 21 January 2020 at 20:48:44 UTC, Enjoys Math wrote:
I have an Integer class in integer.d.  A RationalNumber class 
in rational_number.d, and they each import each other (so that 
could be the issue).  However, this is not working:



   Symbol opBinary(string op : "/")(const Integer z) const
   {
  return new RationalNumber(this, z);
   }

Getting:

Error: class `rational_number.RationalNumber` member `this` is 
not accessible		
Error: template instance `integer.Integer.opBinary!"/"` error 
instantiating		


The error message says that the constructor of `RationalNumber` 
is not accessible, not the `this` reference of `integer.Integer`.


Re: `This` reference not accessible when overloading an operator?

2020-01-21 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/21/20 3:48 PM, Enjoys Math wrote:
I have an Integer class in integer.d.  A RationalNumber class in 
rational_number.d, and they each import each other (so that could be the 
issue).  However, this is not working:



    Symbol opBinary(string op : "/")(const Integer z) const
    {
   return new RationalNumber(this, z);
    }

Getting:

Error: class `rational_number.RationalNumber` member `this` is not 
accessible

Error: template instance `integer.Integer.opBinary!"/"` error instantiating



Do you have a static somewhere that's affecting this? A more complete 
code example might help.


-Steve


`This` reference not accessible when overloading an operator?

2020-01-21 Thread Enjoys Math via Digitalmars-d-learn
I have an Integer class in integer.d.  A RationalNumber class in 
rational_number.d, and they each import each other (so that could 
be the issue).  However, this is not working:



   Symbol opBinary(string op : "/")(const Integer z) const
   {
  return new RationalNumber(this, z);
   }

Getting:

Error: class `rational_number.RationalNumber` member `this` is 
not accessible		
Error: template instance `integer.Integer.opBinary!"/"` error 
instantiating		




Re: Blog Post #0099: A Special Request

2020-01-21 Thread Jan Hönig via Digitalmars-d-learn

On Tuesday, 21 January 2020 at 14:02:59 UTC, Ron Tarrant wrote:
Today's post was requested by Joel Christensen, how to have one 
button affect another. You can find it here: 
https://gtkdcoding.com/2020/01/21/0099-sfx-button-interactions-i-text-labels.html


Hi Ron. Your blog is great. I have saved it for the future. (I 
know it from reddit).

I would also like to request a future blog post about animation.
I know you have done that in the past, but i am thinking of some 
animation triggered by user input (say a button, or some text 
field, which provides parameters for a circle).


Blog Post #0099: A Special Request

2020-01-21 Thread Ron Tarrant via Digitalmars-d-learn
Today's post was requested by Joel Christensen, how to have one 
button affect another. You can find it here: 
https://gtkdcoding.com/2020/01/21/0099-sfx-button-interactions-i-text-labels.html


Re: Type Inference and Try Blocks

2020-01-21 Thread Mitacha via Digitalmars-d-learn

On Monday, 20 January 2020 at 23:16:07 UTC, Henry Claesson wrote:
This isn't a D-specific "problem", but there may be D-specific 
solutions.
I have a function `doSomething()` that returns a Voldemort 
type, and this same function also throws. So, there's this:


try {
auto foo = doSomething();
} catch (AnException e) {
// Do stuff
}

The problem that I'm encountering is that I'd like, assuming no 
exception was thrown, to use foo outside the `try` (or 
`finally`) block to avoid nesting as any operations on `foo` 
from that point onward may also throw. Are there any constructs 
that act as alternatives to try/catch/finally so that I can do 
this?


(This issue could very well stem from poor design and not being 
familiar with programming using exceptions. So feel free to 
ignore.)


Thanks


You could try using `ifThrown` from `std.exception`. It lets you 
turn statement based exception handling into expression based 
one. So, if there is some "default" value in your case you could 
return that.


auto foo = doSomething().ifThrown!AnException("defaultValue");