On Monday, 21 January 2019 at 07:57:58 UTC, Simen Kjærås wrote:
On Saturday, 19 January 2019 at 14:26:31 UTC, Zenw wrote:
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
[...]
how about this
auto With(string code,T)(T value)
{
with(value)
{
mixin(code ~";");
On Saturday, 19 January 2019 at 14:26:31 UTC, Zenw wrote:
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
As an example let's say I have a type 'Window' that represents
a win32 window. I'd like to be able to construct an instance
of the type with some optional parameters that de
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
As an example let's say I have a type 'Window' that represents
a win32 window. I'd like to be able to construct an instance of
the type with some optional parameters that default to some
reasonable settings and create the underlyin
On Fri, 18 Jan 2019 09:39:31 +, John Burton wrote:
> On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
>
>> struct Config {
>> string title;
>> int width;
>> }
>>
>> struct Window {
>> this(Config config)
>
> It likely is a bad idea for a small struct like this but
On Friday, 18 January 2019 at 09:39:31 UTC, John Burton wrote:
It likely is a bad idea for a small struct like this but if it
was much bigger would it makes sense to write this as :-
this(const ref Config config)
Which is what you might do in C++ or does D handle this
differently?
F
On Friday, 18 January 2019 at 09:39:31 UTC, John Burton wrote:
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
struct Config
{
string title;
int width;
}
struct Window
{
this(Config config)
It likely is a bad idea for a small struct like this but if it
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
struct Config
{
string title;
int width;
}
struct Window
{
this(Config config)
It likely is a bad idea for a small struct like this but if it
was much bigger would it makes sense to write this as :-
On Thursday, 17 January 2019 at 16:55:33 UTC, SrMordred wrote:
Yes, but there is a mistake there:
alias is part of the template:
foo(alias x)(){} //note extra parens
than u call like an template:
foo!"a"; //equivalent = foo!("a")();
foo!1;
I see now and thanks.
Matheus.
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
[...]
auto window = Window();
window.title = "My Window";
window.width = 1000;
window.create();
[...]
Is there a better way that's not ugly?
[...]
//usage:
au
On Thursday, 17 January 2019 at 12:11:02 UTC, Matheus wrote:
foo(alias x){}
foo("a");
foo(1);
'x' will be string one time and integer another? Or there is
something that I'm missing.
Matheus.
Yes, but there is a mistake there:
alias is part of the template:
foo(alias x)(){} //note extra
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
Let me throw this idea here:
...
I usually do this too, I like to use struct and then in another
language I use reflection do optimize binding.
Anyway I understood all your code, except for this "alias code"
auto NewWindow( ali
On Thu, Jan 17, 2019 at 10:29:13AM +, John Burton via Digitalmars-d-learn
wrote:
[...]
> Well window was just an example really, my real use case is a similar
> object that needs a lot of configuration where mostly the default
> works but you might want to override, and the config is needed to
On Wednesday, 16 January 2019 at 14:59:01 UTC, Kagamin wrote:> On
Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
auto window = Window(title = "My Window", width = 1000,
fullscreen = true);
In this particular case I would make the constructor take 3
parameters - title, width and h
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
[...]
Let me throw this idea here:
struct Config
{
string title;
int width;
}
struct Window
{
this(Config config)
{
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
As an example let's say I have a type 'Window' that represents
a win32 window. I'd like to be able to construct an instance of
the type with some optional parameters that default to some
reasonable settings and create the underlyin
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
auto window = Window(title = "My Window", width = 1000,
fullscreen = true);
In this particular case I would make the constructor take 3
parameters - title, width and height. Full screen is a rare
functionality and shouldn't clutt
On Wednesday, 16 January 2019 at 11:21:53 UTC, Dukc wrote:
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
This is ok, but I'm not so keen on separating the creation and
construction like this.
Is there a better way that's not ugly?
You can make the constructor a template that
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
auto window = Window();
window.title = "My Window";
window.width = 1000;
window.create();
You can slightly modify it to the way APIs like DirectX or Vulkan
do it.
auto windowinfo = WindowInfo();
windowinfo.title = "My Window";
On Wednesday, 16 January 2019 at 11:21:53 UTC, Dukc wrote:
a template that takes a single struct of arbitrary,
meant "of arbitrary type"
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
This is ok, but I'm not so keen on separating the creation and
construction like this.
Is there a better way that's not ugly?
You can make the constructor a template that takes a single
struct of arbitrary, and inspects (at compi
On Tuesday, 15 January 2019 at 12:15:41 UTC, rikki cattermole
wrote:
On 16/01/2019 1:05 AM, John Burton wrote:
On Tuesday, 15 January 2019 at 11:26:50 UTC, rikki cattermole
wrote:
Longer term, you're better off with the builder.
Thanks for your reply. But what is the builder?
https://en.wiki
On 16/01/2019 1:05 AM, John Burton wrote:
On Tuesday, 15 January 2019 at 11:26:50 UTC, rikki cattermole wrote:
Longer term, you're better off with the builder.
Thanks for your reply. But what is the builder?
https://en.wikipedia.org/wiki/Builder_pattern
One of the few OOP design patterns tha
On Tuesday, 15 January 2019 at 11:26:50 UTC, rikki cattermole
wrote:
Longer term, you're better off with the builder.
Thanks for your reply. But what is the builder?
Creating windows is a very complex task that can balloon in
scope.
Well that was mostly just an example that I thought people
Longer term, you're better off with the builder. Even with named
parameters (2 DIP's are in the queue for adding it).
Creating windows is a very complex task that can balloon in scope.
Being able to hide it away in a separate type can be quite desirable if
you want your windowing library to be
As an example let's say I have a type 'Window' that represents a
win32 window. I'd like to be able to construct an instance of the
type with some optional parameters that default to some
reasonable settings and create the underlying win32 window.
I'd ideally like some syntax like this :-
auto
25 matches
Mail list logo