Let's say I have a D application, with some callbacks from C,
where some arguments to the callbacks are `const char* path`.
What is the recommended way to compare them to D strings? Without
making allocations, if that's possible
On Monday, 20 November 2023 at 07:50:22 UTC, thinkunix wrote:
denis via Digitalmars-d-learn wrote:
```
$ zypper install dmd
$ dmd main.d
Error: cannot find source code for runtime library file
'object.d'
dmd might not be correctly installed. Run 'dmd -man
```
$ zypper install dmd
$ dmd main.d
Error: cannot find source code for runtime library file 'object.d'
dmd might not be correctly installed. Run 'dmd -man' for
installation instructions.
config file: /etc/dmd.conf
$ cat /etc/dmd.conf
;
; dmd.conf file for dmd
;
; dmd will look f
To keep this reply brief, I'll just summarize:
Lots of great takeaways from both of your posts, and a handful of
topics you mentioned that I need to dig into further now. This is
great (I too like D :)
I very much appreciate the extra insight into how things work and
why certain design decis
Many thanks: your post has helped me get past the initial
stumbling blocks I was struggling with. I do have a followup
question.
First, here are my conclusions up to this point, based on your
post above, some additional experimentation, and further research
(for future reference, and for any
Is it possible to write an iterator that does the following,
using a struct and some functions?
- Operates in a foreach loop
- Has BEGIN-like and END-like blocks or functions that are
executed automatically, before and after the iterations
- Initializes variables in the BEGIN block that are
On Friday, 26 June 2020 at 08:15:27 UTC, Jacob Carlborg wrote:
On Friday, 26 June 2020 at 00:30:22 UTC, Denis wrote:
extern(C) void cfunc(void function(int));
extern(C) void dcallback(int x) {...} <-- Why extern(C)?
cfunc(&dcallback);
Can this be rewritten, dropping the prefix f
I have a two questions about calling C functions from D.
(1) When passing a D callback to a C function, is there a way to
write the code without having to prefix the callback declaration
with "extern(C)"?
It's not a big deal adding the prefix to the D function
declaration. It just seems odd
On Tuesday, 23 June 2020 at 21:34:25 UTC, Paul Backus wrote:
If you're open to using Dub packages [...]
Because this is going to be used in almost every program I write,
I need to eliminate outside dependencies as an option.
Nonetheless, thanks for this suggestion.
[2]
https://pbackus.git
Perhaps this thread would have been better titled "Returning a
value and a status", and the question phrased as "What are your
preferred techniques?".
I'm planning to port some of my programs to D, so I'd like to
standardize on one or two techniques for handling this very
common situation, in
Is there a preferred idiom in D for flagging special conditions
when returning from a function call? Here "special conditions"
refers to expected situations (e.g. reaching the end of
something, like EOF) rather than outright errors (so
exception-try-catch is inappropriate).
I've come across m
On Monday, 22 June 2020 at 09:06:35 UTC, Jacob Carlborg wrote:
String **literals** have a terminating null character, to help
with integrating with C functions. But this null character will
disappear when manipulating strings.
You cannot assume that a function parameter of type `string`
will
On Monday, 22 June 2020 at 04:32:32 UTC, Mike Parker wrote:
On Monday, 22 June 2020 at 04:08:10 UTC, Denis wrote:
On Monday, 22 June 2020 at 03:31:17 UTC, Ali Çehreli wrote:
:
string is char[]
wstring is wchar[]
dstring is dchar[]
Got it now. This is the critical piece I missed: I understand
On Monday, 22 June 2020 at 03:31:17 UTC, Ali Çehreli wrote:
:
string is char[]
wstring is wchar[]
dstring is dchar[]
Got it now. This is the critical piece I missed: I understand the
relations between the char types and the UTF encodings (thanks to
your book). But I mistakenly thought that th
On Monday, 22 June 2020 at 03:49:01 UTC, Adam D. Ruppe wrote:
On Monday, 22 June 2020 at 03:43:58 UTC, Denis wrote:
My code reads a UTF-8 encoded file into a buffer and
validates, byte by byte, the UTF-8 encoding along with some
additional validation. If I simply return the UTF-8 encoded
strin
On Monday, 22 June 2020 at 03:24:37 UTC, Adam D. Ruppe wrote:
On Monday, 22 June 2020 at 03:17:54 UTC, Denis wrote:
- First, is there any difference between string, wstring and
dstring?
Yes, they encode the same content differently in the bytes. If
you cast it to ubyte[] and print that out yo
I have a few questions about how strings are stored.
- First, is there any difference between string, wstring and
dstring? For example, a 3-byte Unicode character literal can be
assigned to a variable of any of these types, then printed, etc,
without errors.
- Are the characters of a string
Digging into this a bit further --
POSIX defines a "print" class, which I believe is an exact fit.
The Unicode spec doesn't define this class, which I presume is
why D's std.uni library also omits it. But there is an isprint()
function in libc, which I should be able to use (POSIX here).
This
On Saturday, 20 June 2020 at 01:41:50 UTC, Paul Backus wrote:
It sounds like maybe what you are looking for is Unicode
character categories:
https://en.wikipedia.org/wiki/Unicode_character_property#General_Category
The character validation step could indeed be expressed using
Unicode propert
THE PROBLEM
UTF-8 validation alone is insufficient for ensuring that a file
contains only human-readable text, because control characters are
UTF-8 valid. Apart from tab, newline, carriage return, and a few
less commonly used others considered to be whitespace,
human-readable text files shoul
On Thursday, 18 June 2020 at 17:57:49 UTC, Ali Çehreli wrote:
Here is an earlier experiment of nested templates, which may be
useful in this case.
:
I think you should be able to pass callables as 'alias'
template arguments
Sounds good. This gives me an opportunity to learn how nested
te
On Thursday, 18 June 2020 at 12:50:35 UTC, Stanislav Blinov wrote:
No, there isn't a way to write an operator.
OK, first choice eliminated.
On Thursday, 18 June 2020 at 13:57:39 UTC, Dukc wrote:
No reason to use templates here
pragma(inline, true) auto not(bool cond) { return !cond(); }
I
Let me clarify the requirements and rephrase the question --
REQUIREMENTS
`assert`, `enforce` and the `unless` function I wrote (above) all
allow the condition to be expressed in an affirmative sense, and
they also achieve the goal of readability. These are the initial
requirements.
`unless
On Thursday, 18 June 2020 at 00:43:40 UTC, Stanislav Blinov wrote:
if( ! (configfile.isFile && configfile.extension == ".conf") )
?
That does indeed clean up the compound logic. One is still left
with:
if( !(
if( !
if( !(
if( !
:
I was hoping to get away from all the `not`s too
Is there a cleaner way to implement an "if not" condition check?
WHY NOT JUST USE "IF"?
For data validation, code is cleaner and more intelligible if the
condition being checked is written in an affirmative sense; that
is, in the same way that `assert` is written. This is especially
true when
On Sunday, 14 June 2020 at 15:44:04 UTC, Ali Çehreli wrote:
On 6/14/20 7:43 AM, Denis wrote:> @Kagamin:
>
> On Sunday, 14 June 2020 at 07:16:18 UTC, Kagamin wrote:
>> parameters[param]=Parameter();
>
> I did not realize that you can use a type on the RHS of an
assignment,
Note that it's not just
@Kagamin:
On Sunday, 14 June 2020 at 07:16:18 UTC, Kagamin wrote:
parameters[param]=Parameter();
I did not realize that you can use a type on the RHS of an
assignment, but it is clear and succinct. This syntax will be
very useful going forward -- thank you.
@Stanislav B:
On Sunday, 14 Jun
Hi,
I'm trying to combine a couple of general types (associative
array, struct) in a compound data structure, but without success.
Here is what I'm trying to achieve:
"param" is a string variable
"parameters[param].id" is an integer value
"parameters[param].value" is a string valu
28 matches
Mail list logo