I am trying to implement a simple map function. I found code to
do this in another post but it only seems to work with lambda
functions and I do not understand why. Any help would be greatly
appreciated
```
import std.stdio;
T[] map_vals(T,S)(scope T function(S) f, S[] a){
auto b = new
On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote:
Do I completely not understand what is `nothrow` or why I can't
make function nothrow with just catching StdioException?
This doesn't work
```d
nothrow void hello() {
try {
writeln("Hello, World!")
} catch (StdioException)
On Monday, 21 February 2022 at 03:42:55 UTC, bachmeier wrote:
I tried this
```
import std.json, std.stdio;
void main() {
writeln(parseJSON(`{"a": "path/file"}`,
JSONOptions.doNotEscapeSlashes));
}
```
but the output is
```
{"a":"path\/file"}
```
Is there a way to avoid the escaping of
On Monday, 21 February 2022 at 11:04:46 UTC, Mike Parker wrote:
On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote:
Do I completely not understand what is `nothrow` or why I
can't make function nothrow with just catching StdioException?
D does not have checked exceptions like
On Monday, 21 February 2022 at 11:07:55 UTC, Basile B. wrote:
Yeah there must be another one then. Something actionnable is
the documentation.
What about Mike Parker answer?
On Monday, 21 February 2022 at 11:07:55 UTC, Basile B. wrote:
Yeah there must be another one then. Something actionnable is
the documentation.
This has nothing to do with which exceptions types a function
throws. The compiler doesn't dig into that. You have to catch
`Exception`.
```D
Greetings everyone,
I have a question regarding the use of [relative
links](https://dlang.org/spec/ddoc.html#reference_links) in DDoc.
According to the specification, you can include a reference to an
object that is in scope using square brackets, e.g. `[Object]`.
One of my current projects
On Monday, 21 February 2022 at 11:12:38 UTC, partypooper wrote:
On Monday, 21 February 2022 at 11:07:55 UTC, Basile B. wrote:
Yeah there must be another one then. Something actionnable is
the documentation.
What about Mike Parker answer?
if nothrow fails that's because things are checked.
Do I completely not understand what is `nothrow` or why I can't
make function nothrow with just catching StdioException?
This doesn't work
```d
nothrow void hello() {
try {
writeln("Hello, World!")
} catch (StdioException) {}
}
```
This doest work
```d
nothrow void hello() {
try {
On Monday, 21 February 2022 at 11:21:52 UTC, Mike Parker wrote:
On Monday, 21 February 2022 at 11:07:55 UTC, Basile B. wrote:
[...]
This has nothing to do with which exceptions types a function
throws. The compiler doesn't dig into that. You have to catch
`Exception`.
```D
import
tbh ddoc is pretty bad, you should try my `dub run adrdox`
instead which also creates html but its links actually work.
On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote:
Do I completely not understand what is `nothrow` or why I can't
make function nothrow with just catching StdioException?
This doesn't work
```d
nothrow void hello() {
try {
writeln("Hello, World!")
} catch (StdioException)
On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote:
Do I completely not understand what is `nothrow` or why I can't
make function nothrow with just catching StdioException?
D does not have checked exceptions like Java, so the compiler
doesn't have anyway to verify that any
On Monday, 21 February 2022 at 10:04:16 UTC, steve wrote:
I am trying to implement a simple map function. I found code to
do this in another post but it only seems to work with lambda
functions and I do not understand why. Any help would be
greatly appreciated
```
import std.stdio;
T[]
On Monday, 21 February 2022 at 00:24:54 UTC, Fry wrote:
I'm following the azure pipeline's commands for how it's being
built here:
https://github.com/ldc-developers/ldc/blob/master/.azure-pipelines/2-posix-build_cross_android.yml#L64
You can check the CI logs for the expanded cmdlines, e.g.,
On Monday, 21 February 2022 at 10:57:07 UTC, Basile B. wrote:
On Monday, 21 February 2022 at 10:53:56 UTC, Basile B. wrote:
On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote:
Do I completely not understand what is `nothrow` or why I
can't make function nothrow with just catching
On Monday, 21 February 2022 at 10:58:26 UTC, Basile B. wrote:
more likely UTFException actually
Additionaly catching UTF and Conv exceptions doesn't help.
On Monday, 21 February 2022 at 11:05:42 UTC, partypooper wrote:
On Monday, 21 February 2022 at 10:58:26 UTC, Basile B. wrote:
more likely UTFException actually
Additionaly catching UTF and Conv exceptions doesn't help.
Yeah there must be another one then. Something actionnable is the
On Monday, 21 February 2022 at 11:11:28 UTC, partypooper wrote:
So with such behavior there is no reason at all to make make
function nothrow, if it uses throw functions in its body?
I'm not sure what you mean. If a function throws an exception, it
can't be nothrow.
And as much as I
On Monday, 21 February 2022 at 10:04:16 UTC, steve wrote:
I am trying to implement a simple map function. I found code to
do this in another post but it only seems to work with lambda
functions and I do not understand why. Any help would be
greatly appreciated
```
import std.stdio;
T[]
On Monday, 21 February 2022 at 10:53:56 UTC, Basile B. wrote:
On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote:
Do I completely not understand what is `nothrow` or why I
can't make function nothrow with just catching StdioException?
This doesn't work
```d
nothrow void hello() {
On Monday, 21 February 2022 at 10:53:56 UTC, Basile B. wrote:
On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote:
Do I completely not understand what is `nothrow` or why I
can't make function nothrow with just catching StdioException?
This doesn't work
```d
nothrow void hello() {
See https://run.dlang.io/is/hNaSFh:
```d
import std.sumtype;
struct Unit {}
alias Option(T) = SumType!(T, Unit);
void foobar(T)(Option!T option) {}
void main() {
foobar(Option!int(123));
}
```
If you run this, the compiler should emit this error:
```d
onlineapp.d(14): Error: template
On 2/21/22 09:34, bachmeier wrote:
> I may have to look for an alternative
> JSON library for D. std.json is not the most fun independent of this
issue.
std.json is a very good module. At work, we had to write additional code
to cover its defficiencies.
Looking forward to versioning in
On Monday, 21 February 2022 at 15:13:52 UTC, Kagamin wrote:
On Monday, 21 February 2022 at 09:04:06 UTC, bauss wrote:
Why are we even escaping them by default, it should be the
other way around, that slashes are only escaped if you ask for
it; that's how it literally is in almost every JSON
On Monday, 21 February 2022 at 18:43:18 UTC, Emmanuelle wrote:
If you run this, the compiler should emit this error:
```d
onlineapp.d(14): Error: template `onlineapp.foobar` cannot
deduce function from argument types `!()(SumType!(int, Unit))`
onlineapp.d(8):Candidate is:
On 2/21/22 12:44, steve wrote:
> I had a look at the source code for map but it seems to return a private
> struct, which doesn't help.
What map and other Phobos algorithms return are called Voldemort types
for the reason you state: They are unmentionable. The usual way is to
return 'auto'
On 2/21/22 14:58, Ali Çehreli wrote:
> std.json is a very good module.
Correction: std.json is NOT a very good module.
Ali
On Monday, 21 February 2022 at 17:50:56 UTC, bachmeier wrote:
I looked at the source for `parseJSON` and I see references
only to `JSONOptions.strictParsing` and
`JSONOptions.specialFloatLiterals`. I may be missing something,
but I don't see any option to iterating over every element and
thanks a lot both! Yes I'm aware that map exists already. This
was didactic. I had tried to find out whether lambdas generate
function pointers but also couldn't figure that one out :D
On Monday, 21 February 2022 at 20:18:46 UTC, Paul Backus wrote:
This is a long-standing limitation of the D compiler's template
argument deduction: it cannot "see through" `alias` templates
to deduce the underlying type.
Oh, that’s an unfortunate limitation but at least there’s a
workaround.
following this example in the documentation of map:
```
import std.algorithm.comparison : equal;
import std.conv : to;
alias stringize = map!(to!string);
assert(equal(stringize([ 1, 2, 3, 4 ]), [ "1", "2", "3", "4" ]));
```
I would like to write a function that takes as its parameter a
On Monday, 21 February 2022 at 09:04:06 UTC, bauss wrote:
Why are we even escaping them by default, it should be the
other way around, that slashes are only escaped if you ask for
it; that's how it literally is in almost every JSON library.
Really? I always see escaped slashes in JSON, e.g.
On Monday, 21 February 2022 at 15:35:41 UTC, Vijay Nayar wrote:
I'm a bit surprised I've never heard of `adrdox` before now.
yeah i don't advertise much. it is what runs on my dpldocs.info
website though which auto-generates docs for dub packages.
Regarding ddoc, should I submit a bug
On Monday, 21 February 2022 at 04:02:23 UTC, Steven Schveighoffer
wrote:
On Monday, 21 February 2022 at 03:42:55 UTC, bachmeier wrote:
I tried this
```d
import std.json, std.stdio;
void main() {
writeln(parseJSON(`{"a": "path/file"}`,
JSONOptions.doNotEscapeSlashes));
}
```
but the
On Monday, 21 February 2022 at 17:32:23 UTC, bachmeier wrote:
On Monday, 21 February 2022 at 04:02:23 UTC, Steven
Schveighoffer wrote:
On Monday, 21 February 2022 at 03:42:55 UTC, bachmeier wrote:
I tried this
```d
import std.json, std.stdio;
void main() {
writeln(parseJSON(`{"a":
On Monday, 21 February 2022 at 16:58:43 UTC, Adam D Ruppe wrote:
On Monday, 21 February 2022 at 15:35:41 UTC, Vijay Nayar wrote:
I'm a bit surprised I've never heard of `adrdox` before now.
yeah i don't advertise much. it is what runs on my dpldocs.info
website though which auto-generates
On Monday, 21 February 2022 at 09:04:06 UTC, bauss wrote:
Why are we even escaping them by default, it should be the
other way around, that slashes are only escaped if you ask for
it; that's how it literally is in almost every JSON library.
Escaping slashes as a default is a huge mistake
On Monday, 21 February 2022 at 13:18:01 UTC, Adam D Ruppe wrote:
tbh ddoc is pretty bad, you should try my `dub run adrdox`
instead which also creates html but its links actually work.
I gave it a try and I must say that the documentation is
formatted in a very good way, and as you said, all
On Wednesday, 16 February 2022 at 20:07:09 UTC, Christian Köstlin
wrote:
1. I was pointed by Seb to https://devdocs.io/d/ which offers
an offline mode via html5.
Thanks, that looks promising!
On Monday, 21 February 2022 at 22:58:17 UTC, Ali Çehreli wrote:
On 2/21/22 09:34, bachmeier wrote:
> I may have to look for an alternative
> JSON library for D. std.json is not the most fun independent
of this issue.
std.json is a very good module. At work, we had to write
additional code to
On Tuesday, 22 February 2022 at 00:44:58 UTC, jmh530 wrote:
On Tuesday, 22 February 2022 at 00:36:38 UTC, bachmeier wrote:
[snip]
Yes. std.random is another. I gave up out on the current one.
Luckily I already had external libraries for that before I
started using D.
Have you tried
On Tuesday, 22 February 2022 at 00:36:38 UTC, bachmeier wrote:
[snip]
Yes. std.random is another. I gave up out on the current one.
Luckily I already had external libraries for that before I
started using D.
Have you tried mir.random?
43 matches
Mail list logo