Re: weekly news?

2020-01-22 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 23 January 2020 at 06:27:31 UTC, Mike Parker wrote:



Apparently so. Firefox shows me a 404 for the URL with the 
parameter ?relatedposts=1. Must be something in the Wordpress 
settings triggering the fetch. Maybe with Jetpack. I wonder why 
Chrome doesn't show it. I'll look into it.


So it's not happening with every post. And now I've seen that 
when it does happen, it also returns 404 for the URL with no 
parameters. I'm also seeing it in Chrome now.


The option to show related posts in Jetpack is turned off. So I 
have no clue why that keeps showing up for some posts and not 
others.


Re: weekly news?

2020-01-22 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 23 January 2020 at 06:23:14 UTC, Mike Parker wrote:



I'm not getting any 404s in the network tab in Chrome's dev 
tools. Even on a reload. Most everything is 200, with a handful 
of 204s. A couple are 302 or 304, and there's one 101. Am I 
missing something?


Apparently so. Firefox shows me a 404 for the URL with the 
parameter ?relatedposts=1. Must be something in the Wordpress 
settings triggering the fetch. Maybe with Jetpack. I wonder why 
Chrome doesn't show it. I'll look into it.


Re: weekly news?

2020-01-22 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 23 January 2020 at 00:58:10 UTC, Adam D. Ruppe wrote:

On Thursday, 23 January 2020 at 00:52:10 UTC, Mike Parker wrote:
Got any examples? No one has reported this to me before and I 
haven’t encountered a 404 in a while.


Almost all of them!

Hit F12 to open browser tools and notice the network tab:

https://dlang.org/blog/2020/01/08/recent-d-compiler-releases/
https://dlang.org/blog/2020/01/04/dconf-2020-double-decker-edition/

and more. The HTML is displayed, but it has the 404 code so 
according to the http spec you are actually displaying it all 
as error pages!


I'm not getting any 404s in the network tab in Chrome's dev 
tools. Even on a reload. Most everything is 200, with a handful 
of 204s. A couple are 302 or 304, and there's one 101. Am I 
missing something?


Re: weekly news?

2020-01-22 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 23 January 2020 at 00:52:10 UTC, Mike Parker wrote:
Got any examples? No one has reported this to me before and I 
haven’t encountered a 404 in a while.


Almost all of them!

Hit F12 to open browser tools and notice the network tab:

https://dlang.org/blog/2020/01/08/recent-d-compiler-releases/
https://dlang.org/blog/2020/01/04/dconf-2020-double-decker-edition/

and more. The HTML is displayed, but it has the 404 code so 
according to the http spec you are actually displaying it all as 
error pages!


Re: weekly news?

2020-01-22 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 23:08:09 UTC, Russel Winder 
wrote:
On Wed, 2020-01-22 at 22:48 +, Mike Parker via 
Digitalmars-d-learn

wrote:
[…]


To D Blog has an RSS feed:

http://dlang.org/blog/index.php/feed/


[…]

This URL doesn't seem to work for me.

It redirects to:

https://dlang.org/blog/feed/

which gives "file not found"


For me, the first link redirects to:

http://feeds.feedburner.com/OfficialDBlog


Re: weekly news?

2020-01-22 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 23:23:41 UTC, Adam D. Ruppe 
wrote:
Several pages on the official blog give code 404 even though 
they work. Your RSS reader probably just isn't checking the 
code, but the browser is.


These should all be fixed on the server... could be hurting seo 
too.


Got any examples? No one has reported this to me before and I 
haven’t encountered a 404 in a while.


Re: weekly news?

2020-01-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 23:13:30 UTC, Russel Winder 
wrote:

On Wed, 2020-01-22 at 23:08 +, Russel Winder wrote:

which gives "file not found"


And yet it works fine as an RSS feed!


Several pages on the official blog give code 404 even though they 
work. Your RSS reader probably just isn't checking the code, but 
the browser is.


These should all be fixed on the server... could be hurting seo 
too.


Re: weekly news?

2020-01-22 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2020-01-22 at 23:08 +, Russel Winder wrote:
> On Wed, 2020-01-22 at 22:48 +, Mike Parker via Digitalmars-d-
> learn
> wrote:
> […]
> > To D Blog has an RSS feed:
> > 
> > http://dlang.org/blog/index.php/feed/
> > 
> […]
> 
> This URL doesn't seem to work for me.
> 
> It redirects to:
> 
> https://dlang.org/blog/feed/
> 
> which gives "file not found"

And yet it works fine as an RSS feed!

> 
-- 
Russel.
===
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



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


Re: weekly news?

2020-01-22 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2020-01-22 at 22:48 +, Mike Parker via Digitalmars-d-learn
wrote:
[…]
> 
> To D Blog has an RSS feed:
> 
> http://dlang.org/blog/index.php/feed/
> 
[…]

This URL doesn't seem to work for me.

It redirects to:

https://dlang.org/blog/feed/

which gives "file not found"


-- 
Russel.
===
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk



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


Re: weekly news?

2020-01-22 Thread Mike Parker via Digitalmars-d-learn

On Wednesday, 22 January 2020 at 18:53:49 UTC, mark wrote:

Is there a "D weekly news" I could do an email subscription to?
Or at least a way to get notified by email when a new item 
appears on https://dlang.org/blog/ ?


This Week in D linked above is great for a weekly summary.

To D Blog has an RSS feed:

http://dlang.org/blog/index.php/feed/

All D Blog posts are automatically shared on Twitter and Facebook:

https://twitter.com/D_Programming
https://www.facebook.com/dlang.org/

Info on subscribing to the newsgroups and mailing lists is 
available at:


https://www.digitalmars.com/NewsGroup.html

You’ll want digitalmars.D.announce for the Announce forum.

All thread-starting posts in Announce also go to the DLang 
Newsfeed Twitter:


https://twitter.com/dlang_ng


Re: Blog Post #0099: A Special Request

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

On Wednesday, 22 January 2020 at 15:29:44 UTC, Jan Hönig wrote:


Yes something in that manner.
I am not familiar with GTK, i have done a few things in QT.
I am mainly interested in the information passing.
When i make some change to the input || hit enter || hit the 
button, the scene will change accordingly.


For a more satisfying example, you could have a ball on one 
line. Below that you have a horizontal slider. Whenever you 
move the slider, the ball on the line will move accordingly.


Would you be able to do a quick sketch/rough drawing of this? 
Perhaps before and after drawings? I wanna make sure I understand 
exactly what you're looking for. I don't know if this forum will 
allow images, so perhaps we could switch over to email 
(gtkdcod...@gmail.com) so you can attach them.


Re: Blog Post #0099: A Special Request

2020-01-22 Thread Ron Tarrant via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 09:18:51 UTC, Ferhat Kurtulmuş 
wrote:


Another useful tutorial would be something using bindProperty 
and/or bindPropertyWithClosures. Once I used bindProperty with 
vala, but I think there is no any example to do it with gtkd.


I found a bindProperty() function in gobject/ObjectG.d. Is this 
what you're referring to?




Re: Blog Post #0099: A Special Request

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

On Tuesday, 21 January 2020 at 22:12:10 UTC, Antonio Corbi wrote:

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



Do you still have the Maurer Rose example?


I had to look this up. I'd never heard of it before. That being 
said...



Do you think it could fit this kind of example?


When I say "demo" I'm talking about examples of how to do various 
GTK GUI stuff rather than mathematical exercises. Trying to do 
this mathematical/drawing exercise, I'd be waaay out of my 
element. The few simple math/draw examples I did in Cairo (posts 
#0057 to #0064) is about my limit as far as math goes.


However, I can point you at this repository of Java examples: 
https://github.com/iabin/Maurer-Rose/tree/master/src


Using the methods outlined in the posts I've listed, you should 
be able to port it over from Java to D. I'm not a mathematician, 
so I wouldn't be of much help.


I wish you the best of luck on this endeavour.


Re: Lexicographic comparison of arrays (of chars)

2020-01-22 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 15:11:09 UTC, Jacob Carlborg 
wrote:

int opCmp()(const scope typeof(this) that) const @nogc
{
auto a = this[];
auto b = that[];
return a < b ? -1 : (a > b);
}

--
/Jacob Carlborg


I see. Good to know. Thanks


Re: Type Inference and Try Blocks

2020-01-22 Thread Henry Claesson via Digitalmars-d-learn
Thank you for the help and input, Adam and Mitacha. I don't know 
why I thought I must use `try` with every throwable function call 
instead "bundling" those calls into one `try` block. Not 
"bundling" defeats one of the benefits of exceptions. Also, 
`ifThrown` is quite interesting.

Again, thank you!


Re: weekly news?

2020-01-22 Thread Cym13 via Digitalmars-d-learn

On Wednesday, 22 January 2020 at 18:53:49 UTC, mark wrote:

Is there a "D weekly news" I could do an email subscription to?
Or at least a way to get notified by email when a new item 
appears on https://dlang.org/blog/ ?


There's http://dpldocs.info/this-week-in-d/Blog.html which is 
unofficial but interesting and weekly. AFAIK there's no 
newsletter but it provides a RSS feed.


Otherwise I think the easiest is to use the fact that this forum 
isn't a forum but a newsgroup (hence available by mail) to 
subscribe to Announce. Blog entries in particular are announced 
there.


weekly news?

2020-01-22 Thread mark via Digitalmars-d-learn

Is there a "D weekly news" I could do an email subscription to?
Or at least a way to get notified by email when a new item 
appears on https://dlang.org/blog/ ?




Re: trying to understand in, inout, and ref...

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

On 1/22/20 10:33 AM, Adam D. Ruppe wrote:



BUT if you change the length of it or reallocate it in any way those 
changes are NOT seen outside.


So with AAs and slices, if you just want to work with existing elements, 
no need for ref. But if you are going to do any kind of resizing - 
adding or removing elements - ref is likely what you want.


So just to clarify this a bit for AAs. Adding or removing elements from 
an AA DOES get seen outside, even if you don't pass by ref, except for 
one case -- the AA is in its initial state.


The reason is because an AA is actually a pointer-to-implementation 
(pImpl) struct, which is initialized to null, but allocated on first 
element added.


So if you don't add any elements, and pass it by value, you are passing 
null by value, and adding elements will allocate it. But the result 
doesn't get seen back at the parameter you passed.


However, if you add one element, and then pass it, the implementation is 
already allocated and does not change locations. So then you can add 
more elements even if you pass by value, and the implementation stays at 
the same location.


example:

void foo(int[int] p)
{
   p[1] = 1; p[2] = 2;
}

int[int] aa;

foo(aa);
assert(aa.length == 0); // new allocation in foo not seen
aa[0] = 0; // first initialization, no longer null
foo(aa);
assert(aa.length == 3); // now, you see the changes

aa.clear(); // remove all elements, but don't deallocate.
assert(aa.length == 0);
foo(aa);
assert(aa.length == 2); // was already preallocated, so impl stays the same.

This aspect is very confusing to many people.

-Steve


Re: trying to understand in, inout, and ref...

2020-01-22 Thread mark via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 15:33:44 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 22 January 2020 at 15:26:06 UTC, mark wrote:
I've done this but my impression from the docs is that passing 
slices and associative arrays is already done by reference so 
these aren't needed?


They are pointers passed by value.

If you're familiar with C, think of passing

struct Array {
   size_t length;
   element* ptr;
}


The elements are passed by ref there; they aren't copied to the 
function and any changes to them will be visible outside.


BUT if you change the length of it or reallocate it in any way 
those changes are NOT seen outside.


So with AAs and slices, if you just want to work with existing 
elements, no need for ref. But if you are going to do any kind 
of resizing - adding or removing elements - ref is likely what 
you want.


Thanks - that's exactly what I needed to know!

(I'm also very much enjoying your D Cookbook.)


Re: Lexicographic comparison of arrays (of chars)

2020-01-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 22, 2020 7:50:01 AM MST Per Nordlöw via Digitalmars-d-
learn wrote:
> On Wednesday, 22 January 2020 at 10:19:38 UTC, Jacob Carlborg
>
> wrote:
> > That looks like it's for internal use. There is a `compare`
> > method in the `TypeInfo` of each type.
>
> Will that incur an extra runtime cost compared to __cmp?

Regardless of the overhead involved, you really shouldn't be calling
functions that start with __ or any that are in an internal package. They're
not intended to be called directly by anything outside of druntime or
Phobos, and they could change at any time. In the case of
core.internal.array, the only reason that any of it is even exposed is
because it had to be when it was changed to a template.

- Jonathan M Davis






Re: trying to understand in, inout, and ref...

2020-01-22 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 22 January 2020 at 15:26:06 UTC, mark wrote:
I've done this but my impression from the docs is that passing 
slices and associative arrays is already done by reference so 
these aren't needed?


They are pointers passed by value.

If you're familiar with C, think of passing

struct Array {
   size_t length;
   element* ptr;
}


The elements are passed by ref there; they aren't copied to the 
function and any changes to them will be visible outside.


BUT if you change the length of it or reallocate it in any way 
those changes are NOT seen outside.


So with AAs and slices, if you just want to work with existing 
elements, no need for ref. But if you are going to do any kind of 
resizing - adding or removing elements - ref is likely what you 
want.


Re: trying to understand in, inout, and ref...

2020-01-22 Thread mark via Digitalmars-d-learn

On Wednesday, 22 January 2020 at 14:23:53 UTC, Paul Backus wrote:

On Wednesday, 22 January 2020 at 10:49:07 UTC, mark wrote:
Regarding generate(): allWords should never be changed 
(generate is called in a loop with the same allWords every 
time) -- so should it be `in WordSet allWords`?


For parameters that shouldn't be changed, use const. So it 
should be `const WordSet allWords`.


That single change produces (using LDC 1.19.0 - D 2.089.1):

./wordladder.d(52): Error: function wordladder.update(string[] 
ladder, int[string] words, const(int[string]) compatibles) is not 
callable using argument types (string[], const(int)[string], 
const(int)[string])
./wordladder.d(52):cannot pass argument words of type 
const(int)[string] to parameter int[string] words
Failed: ["/home/mark/opt/ldc2-1.19.0-linux-x86_64/bin/ldmd2", 
"-v", "-o-", "./wordladder.d", "-I."]


So I've rolled it back.

Regarding update(): ladder and words are both modified in 
update -- so should they be `ref WordList ladder` and `ref 
WordSet words`? And if so, do I need to change the update() 
call in the generate() function?


Yes, they should be `ref`. No, you do not have to change the 
update() call.


I've done this but my impression from the docs is that passing 
slices and associative arrays is already done by reference so 
these aren't needed? (I can't tell yet because I haven't written 
the modifying code.)


compatibles is (will be) modified in generate() but not in 
update(), so should it be `in WordSet compatibles`?


It should be `const WordSet compatibles`.


Done that and it compiles fine.

Thanks.



Re: Blog Post #0099: A Special Request

2020-01-22 Thread Jan Hönig 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?


Yes something in that manner.
I am not familiar with GTK, i have done a few things in QT.
I am mainly interested in the information passing.
When i make some change to the input || hit enter || hit the 
button, the scene will change accordingly.


For a more satisfying example, you could have a ball on one line. 
Below that you have a horizontal slider. Whenever you move the 
slider, the ball on the line will move accordingly.


Re: Lexicographic comparison of arrays (of chars)

2020-01-22 Thread Jacob Carlborg via Digitalmars-d-learn

On Wednesday, 22 January 2020 at 14:50:01 UTC, Per Nordlöw wrote:


Will that incur an extra runtime cost compared to __cmp?


I haven't looked at how `__cmp` is implemented but I would guess 
there's some extra overhead. Need to get type info and then there 
will be several virtual method calls involved. Seems to be one of 
the initial call to `compare` and then one for each element of 
the array.


BTW, why don't you implement `opCmp` with the built-in comparison 
operators. Those are going to get lower to a call to `__cmp`. 
Something like this:


int opCmp()(const scope typeof(this) that) const @nogc
{
auto a = this[];
auto b = that[];
return a < b ? -1 : (a > b);
}

--
/Jacob Carlborg




Re: Lexicographic comparison of arrays (of chars)

2020-01-22 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 10:19:38 UTC, Jacob Carlborg 
wrote:
That looks like it's for internal use. There is a `compare` 
method in the `TypeInfo` of each type.


Will that incur an extra runtime cost compared to __cmp?


Re: trying to understand in, inout, and ref...

2020-01-22 Thread Paul Backus via Digitalmars-d-learn

On Wednesday, 22 January 2020 at 10:49:07 UTC, mark wrote:
Regarding generate(): allWords should never be changed 
(generate is called in a loop with the same allWords every 
time) -- so should it be `in WordSet allWords`?


For parameters that shouldn't be changed, use const. So it should 
be `const WordSet allWords`.


Regarding update(): ladder and words are both modified in 
update -- so should they be `ref WordList ladder` and `ref 
WordSet words`? And if so, do I need to change the update() 
call in the generate() function?


Yes, they should be `ref`. No, you do not have to change the 
update() call.


compatibles is (will be) modified in generate() but not in 
update(), so should it be `in WordSet compatibles`?


It should be `const WordSet compatibles`.


trying to understand in, inout, and ref...

2020-01-22 Thread mark via Digitalmars-d-learn

I have these code snippets:

alias WordList = string[];
alias WordSet = int[string]; // key = word; value = 0

WordList generate(WordSet allWords, int steps) {
WordList ladder; // will be changed in update()
auto words = allWords.dup; // will be changed in update()
auto compatibles = allWords.dup; // will be changed in this 
function

auto prev = update(ladder, words, compatibles);
// TODO
return ladder;
}

string update(WordList ladder, WordSet words, WordSet 
compatibles) {

auto word = ""; // TODO random string from compatibles
// TODO remove word from words; add word to ladder
return word;
}

Regarding generate(): allWords should never be changed (generate 
is called in a loop with the same allWords every time) -- so 
should it be `in WordSet allWords`?


Regarding update(): ladder and words are both modified in update 
-- so should they be `ref WordList ladder` and `ref WordSet 
words`? And if so, do I need to change the update() call in the 
generate() function? compatibles is (will be) modified in 
generate() but not in update(), so should it be `in WordSet 
compatibles`?


Re: Lexicographic comparison of arrays (of chars)

2020-01-22 Thread Jacob Carlborg via Digitalmars-d-learn

On Wednesday, 22 January 2020 at 08:44:15 UTC, Per Nordlöw wrote:


I just found

import core.internal.array.comparison : __cmp;

I presume that is a better alternative if Phobos' independence 
is desired.


That looks like it's for internal use. There is a `compare` 
method in the `TypeInfo` of each type.


https://github.com/dlang/druntime/blob/2fa694319da397d72ab09cb336f3d588107278c1/src/object.d#L541

--
/Jacob Carlborg



Re: Blog Post #0099: A Special Request

2020-01-22 Thread Ferhat Kurtulmuş 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


Another useful tutorial would be something using bindProperty 
and/or bindPropertyWithClosures. Once I used bindProperty with 
vala, but I think there is no any example to do it with gtkd.


Re: Lexicographic comparison of arrays (of chars)

2020-01-22 Thread Per Nordlöw via Digitalmars-d-learn

On Wednesday, 22 January 2020 at 08:30:55 UTC, Per Nordlöw wrote:
is a suitable definition of `opCmp` for `SSOString` in terms of 
independence of Phobos' `std.algorithm.comparison.cmp`.


I just found

import core.internal.array.comparison : __cmp;

I presume that is a better alternative if Phobos' independence is 
desired.


Lexicographic comparison of arrays (of chars)

2020-01-22 Thread Per Nordlöw via Digitalmars-d-learn

I've implement a small size optimized `string` at

https://github.com/nordlow/phobos-next/blob/c35fa4052738af0cd7ad39a9fa715b5ec29c7bba/src/nxt/sso_string.d

I'm now wondering whether or not its definition of comparison at

https://github.com/nordlow/phobos-next/blob/c35fa4052738af0cd7ad39a9fa715b5ec29c7bba/src/nxt/sso_string.d#L248

is a suitable definition of `opCmp` for `SSOString` in terms of 
independence of Phobos' `std.algorithm.comparison.cmp`.


I'm asking because comparison of `string`s can be done directly as

assert("a" < "b")

without any dependence on Phobos.

Is there a builtin definition of array (of `char`) comparison 
defined somewhere in druntime?


Further, does

"a" < "b"

perform autodecoding of UTF-8 sequences?