On Tue, Jan 10, 2023 at 03:18:54AM +, matheus via Digitalmars-d-learn wrote:
> On Tuesday, 10 January 2023 at 01:22:33 UTC, H. S. Teoh wrote:
> > ...
> >
> > Here's a challenge. Given an input year, for example, "2023",
> > write a program that outputs (for the corresponding year):
> > ...
>
On Tue, Jan 10, 2023 at 12:17:18AM +, Paul via Digitalmars-d-learn wrote:
> Greetings Dlang-ers
> I was wondering if anyone knew of any coding challenges available
> where the input and output are specified and its left to the
> programmer to find a solution?
Here's a challenge. Given an
On Thu, Jan 05, 2023 at 10:46:07PM +, thebluepandabear via
Digitalmars-d-learn wrote:
> On Thursday, 5 January 2023 at 17:36:55 UTC, H. S. Teoh wrote:
[...]
> > ```D
> > foreach (BoardSize boardSize; arr) {
> > Button button = new Button();
> > button.text = format("%sx%s",
On Thu, Jan 05, 2023 at 08:18:42PM +, DLearner via Digitalmars-d-learn
wrote:
> On Thursday, 5 January 2023 at 19:54:01 UTC, H. S. Teoh wrote:
[...]
> > core.stdc.stdlib.{malloc,free} *is* the exact same malloc/free that
> > C uses, it has nothing to do with the GC. The allocated memory is
>
On Thu, Jan 05, 2023 at 07:49:38PM +, DLearner via Digitalmars-d-learn
wrote:
> Suppose there is a D main program (not marked anywhere with @nogc),
> that _both_
>
> A: Calls one or more C functions that themselves call malloc/free; and
> also
> B: Calls one or more D functions that
On Thu, Jan 05, 2023 at 02:32:17PM +, Dom DiSc via Digitalmars-d-learn
wrote:
[...]
> I think this is really another usecase for @property: we should forbid the
> function call syntax for them (so one needs to use them like a variable).
[...]
> Properties are not functions. If you want a
On Thu, Jan 05, 2023 at 11:55:33AM +, thebluepandabear via
Digitalmars-d-learn wrote:
[...]
> ```D
> foreach (BoardSize boardSize; arr) {
> Button button = new Button();
> button.text = format("%sx%s", boardSize[0], boardSize[1]);
> button.onButtonClick = {
>
On Thu, Jan 05, 2023 at 06:32:47AM +, areYouSureAboutThat via
Digitalmars-d-learn wrote:
[...]
> Second, to be sure your getting the correct results, it would be nice
> if there was a 'category of type' in std.traits for:
>
> isAllocatedOnStack
> isAllocatedOnHeap
>
> As it is, your just
On Wed, Jan 04, 2023 at 01:20:12PM -0800, Ali Çehreli via Digitalmars-d-learn
wrote:
> On 1/4/23 12:02, Steven Schveighoffer wrote:
> > On 1/4/23 2:27 PM, Ali Çehreli wrote:
>
> >> I put the objects into a 2-length
> >> static array but the difference was still 0x20. (?)
> >
> > Are you putting
On Wed, Jan 04, 2023 at 09:51:05AM -0800, Ali Çehreli via Digitalmars-d-learn
wrote:
> On 1/3/23 20:01, Paul wrote:
>
> > Size Alignment Type
> > =
> >17 8 MyClass
> >
> > MyClassObj1 MyClassObj2
> > 27727202000 27727202020
> > ```
> > If my
On Sun, Jan 01, 2023 at 02:18:23AM +, Salih Dincer via Digitalmars-d-learn
wrote:
> On Sunday, 1 January 2023 at 01:20:02 UTC, Ali Çehreli wrote:
> > On 12/31/22 16:42, H. S. Teoh wrote:
> >
> > - runtime: The D runtime.
>
> Sometimes I see runtime facilities used as compile time and I'm
On Sun, Jan 01, 2023 at 12:35:40AM +, Paul via Digitalmars-d-learn wrote:
> Hello. Thanks for any assistance.
>
> Can I acquire the address of a class object, not a class variable
> (i.e. the instantiations of the class) but the object definition
> itself?
>
> ```d
> class MyClass {char c}
On Wed, Dec 28, 2022 at 02:31:45AM +, thebluepandabear via
Digitalmars-d-learn wrote:
> I am reading through the free book on learning D by Ali Çehreli and I
> am having difficulties understanding the difference between compile
> time execution and run time execution in D language.
It's very
On Fri, Dec 23, 2022 at 03:21:24PM +, jwatson-CO-edu via
Digitalmars-d-learn wrote:
> On Friday, 23 December 2022 at 00:00:06 UTC, H. S. Teoh wrote:
[...]
> > My personal guess is that you forgot a `ref` somewhere when you pass
> > the RNG to a function. Given that due to historical accident
On Thu, Dec 22, 2022 at 08:17:56PM +, jwatson-CO-edu via
Digitalmars-d-learn wrote:
> On Thursday, 22 December 2022 at 17:33:48 UTC, Paul Backus wrote:
> > So, as far as I can tell, there is nothing wrong with your code, and
> > the random number generator is working as intended.
> >
> >
On Thu, Dec 22, 2022 at 12:43:28AM +, thebluepandabear via
Digitalmars-d-learn wrote:
> Say you have the following function that takes in a `ref` parameter:
>
> ```D
> void modify(ref int num) {
> num += 5;
> }
> ```
>
> Does the compiler turn that into the code below?
>
> ```D
> void
On Sat, Dec 17, 2022 at 02:36:10AM +, thebluepandabear via
Digitalmars-d-learn wrote:
[...]
> Thanks, I've tried to mark it with `@safe` and it did give me a
> warning.
>
> I was also wondering, why is this code valid?
>
> ```D
> int[] numbersForLaterUse;
>
> @safe void foo(int[] numbers)
On Fri, Dec 16, 2022 at 05:39:08PM -0800, H. S. Teoh via Digitalmars-d-learn
wrote:
[...]
> If you really want to see what could possibly have gone wrong, try
> this version of the code:
[...]
> The results will likely differ depending on your OS and specific
> environment; but
On Sat, Dec 17, 2022 at 12:23:32AM +, thebluepandabear via
Digitalmars-d-learn wrote:
[...]
> ```D
> int[] numbersForLaterUse;
>
> void foo(int[] numbers...) {
>numbersForLaterUse = numbers;
> }
>
> struct S {
> string[] namesForLaterUse;
>
> void foo(string[] names...) {
>
On Fri, Dec 09, 2022 at 12:51:27PM +0100, Christian Köstlin via
Digitalmars-d-learn wrote:
> On 09.12.22 02:27, H. S. Teoh wrote:
[...]
> > https://github.com/dlang/phobos/pull/8646
[...]
> Thanks a lot ...
> that was fast.
It only took a minute to fix. :-D
> Is there also an implementation
On Thu, Dec 08, 2022 at 05:21:52PM -0800, H. S. Teoh via Digitalmars-d-learn
wrote:
[...]
> I'll see if I can reword this to be more explicit.
[...]
https://github.com/dlang/phobos/pull/8646
T
--
Don't modify spaghetti code unless you can eat the consequences.
On Thu, Dec 08, 2022 at 09:15:45PM +0100, Christian Köstlin via
Digitalmars-d-learn wrote:
> Recently I stumbled upon a small issue in dlang's docs.
> I wanted to look up uniq in std.algorithm. Started from
> https://dlang.org/phobos/std_algorithm.html and clicked uniq, no
> problem, all good.
On Tue, Dec 06, 2022 at 11:07:32PM +, johannes via Digitalmars-d-learn
wrote:
> //-- the result should be f.i. "the sun is shining"
> //-- sqlite3_column_text returns a constant char* a \0 delimited c-string
> printf("%s\n",sqlite3_column_text(res, i));
> writeln(sqlite3_column_text(res, i));
On Sun, Dec 04, 2022 at 04:33:35PM +, rempas via Digitalmars-d-learn wrote:
> First a little bit of theory. A pointer just points to a memory
> address which is a number. So when I add "10" to this pointer, it will
> point ten bytes after the place it was pointing to, right?
This is true only
On Fri, Dec 02, 2022 at 11:47:30PM +, thebluepandabear via
Digitalmars-d-learn wrote:
> On Friday, 2 December 2022 at 23:44:28 UTC, thebluepandabear wrote:
> > > :-D
> > >
> > > (Exercise for the reader: what's the Hausdorff dimension of the
> > > set of strings over Unicode space? :-P)
> >
On Fri, Dec 02, 2022 at 02:32:47PM -0800, Ali Çehreli via Digitalmars-d-learn
wrote:
> On 12/2/22 13:44, rikki cattermole wrote:
>
> > Yeah you're right, its code unit not code point.
>
> This proves yet again how badly chosen those names are. I must look it
> up every time before using one or
On Fri, Dec 02, 2022 at 09:18:44PM +, thebluepandabear via
Digitalmars-d-learn wrote:
> Hello (noob question),
>
> I am reading a book about D by Ali, and he talks about the different
> char types: char, wchar, and dchar. He says that char stores a UTF-8
> code unit, wchar stores a UTF-16
On Wed, Nov 30, 2022 at 03:07:44AM +, thebluepandabear via
Digitalmars-d-learn wrote:
> I am reading through Ali's book about D, and he gives the following
> examples for an overflow:
[...]
> The result overflows and is 1705032704.
>
> Also for the second example, it overflows and comes up
On Fri, Nov 18, 2022 at 11:51:42AM +, thebluepandabear via
Digitalmars-d-learn wrote:
A question I have been thinking about whilst using D is how
often I
should be using const.
You should use it as often as you need to use it, and no more.
If you
don't need to use it, don't use it.
On Thu, Nov 17, 2022 at 10:16:04PM +, jwatson-CO-edu via
Digitalmars-d-learn wrote:
> On Thursday, 17 November 2022 at 21:05:43 UTC, H. S. Teoh wrote:
[...]
> > struct Atom {
> > F_Type kind;
> > union { // anonymous union
> > Atom*
On Thu, Nov 17, 2022 at 08:54:46PM +, jwatson-CO-edu via
Digitalmars-d-learn wrote:
[...]
> ```d
> enum F_Type{
> CONS, // Cons pair
> STRN, // String/Symbol
> NMBR, // Number
> EROR, // Error object
> BOOL, // Boolean value
> FUNC, // Function
> }
>
> struct Atom{
>
On Wed, Nov 16, 2022 at 10:51:31PM +, bioinfornatics via
Digitalmars-d-learn wrote:
> Dear community,
>
> I look some day ago to the D wasm page:
> -> https://wiki.dlang.org/Generating_WebAssembly_with_LDC
>
> And since then I ask myself can we at compile time convert a D code
> to an
On Thu, Nov 10, 2022 at 11:26:45PM +, Alexander Zhirov via
Digitalmars-d-learn wrote:
> I have an array of self-written class `A`. I'm sorry for my tactlessness,
> but I'm confused about the modules. How do I correctly find a specific
> object `fragment` inside the array and delete it? I
On Thu, Nov 10, 2022 at 07:07:33PM +, Imperatorn via Digitalmars-d-learn
wrote:
> On Thursday, 10 November 2022 at 16:34:53 UTC, Ali Çehreli wrote:
> > On 11/9/22 11:30, Vladimir Panteleev wrote:
> > > On Wednesday, 9 November 2022 at 19:05:58 UTC, Ali Çehreli
> > > wrote:
> > >> Running the
Happened to stumble across this today, which I thought is a relevant, if
sadly humorous, take on build systems:
https://pozorvlak.dreamwidth.org/174323.html
T
--
ASCII stupid question, getty stupid ANSI.
On Fri, Nov 04, 2022 at 11:19:17PM +, Anonymouse via Digitalmars-d-learn
wrote:
> [#20699](https://issues.dlang.org/show_bug.cgi?id=20699) must be
> non-trivial to fix, so I'm exploring makefiles. If possible I'd like
> to keep dub for dependency management though, just not for actual
>
On Fri, Nov 04, 2022 at 07:34:58PM +, jmh530 via Digitalmars-d-learn wrote:
> On Friday, 4 November 2022 at 19:17:04 UTC, Adam D Ruppe wrote:
> > On Friday, 4 November 2022 at 19:10:33 UTC, jmh530 wrote:
> > > If you don't plan to use private(package_name), then I don't know
> > > what the
On Wed, Nov 02, 2022 at 09:16:22PM +0100, Christian Köstlin via
Digitalmars-d-learn wrote:
> On 02.11.22 20:16, H. S. Teoh wrote:
[...]
> > IMO, the ideal situation is a hybrid situation: the underlying build
> > mechanism should be purely declarative, because otherwise the
> > complexity just
On Thu, Nov 03, 2022 at 08:51:52AM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
> On 11/3/22 03:00, Bruno Pagis wrote:
>
> >void print() {
> > writeln("array = ", this.array);
> >}
>
> Similar to Paul Backus's program but I would try to avoid the file system
> for unit tests
On Thu, Nov 03, 2022 at 04:41:14AM +, Siarhei Siamashka via
Digitalmars-d-learn wrote:
[...]
> ```D
> @safe:
> import std.stdio;
> class A {
> void foo() { writeln("foo"); }
> }
> void main() {
> auto a1 = new A;
> a1.foo(); // prints "foo"
> A a2;
> a2.foo(); // Segmentation fault
On Wed, Nov 02, 2022 at 03:08:36PM +, JN via Digitalmars-d-learn wrote:
> On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote:
> > sh("touch %s".format(t.name));
>
> One of the problems of many Make-like tools is that they offer lots of
> freedom, especially
On Tue, Nov 01, 2022 at 10:37:57AM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
> On 11/1/22 10:27, H. S. Teoh wrote:
>
> > Maybe try running Digger to reduce the code for you?
>
> Did you mean dustmite, which is accessible as 'dub dustmite
> ' but I haven't used it.
Oh yes, sorry, I
On Tue, Nov 01, 2022 at 05:19:56PM +, mw via Digitalmars-d-learn wrote:
> My program received signal SIGSEGV, Segmentation fault.
>
> Its simplified structure looks like this:
>
> ```
> void foo() {
> ...
> writeln("done"); // saw this got printed!
> }
>
> int main() {
> foo();
>
On Thu, Oct 27, 2022 at 06:20:10PM +, Imperatorn via Digitalmars-d-learn
wrote:
> On Thursday, 27 October 2022 at 17:17:01 UTC, ab wrote:
> > Hi,
> >
> > when trying to compare different implementations of the optimized
> > builds of a pure function using benchmark from
> >
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via Digitalmars-d-learn
wrote:
> Hi
>
> Never used DUB before.
> Wanted to use a function stored in a module outside the main source.
>
> Main source has `import ;`
>
> Put a line into the JSON: `"importPaths": "C:\\Users\\..."` pointing
> to
On Wed, Oct 26, 2022 at 12:16:55AM +, Salih Dincer via Digitalmars-d-learn
wrote:
[...]
> I've known D for more than 10 years, but the topic we're talking about
> still seems strange to me. The explanations given are not enough for
> me, I'm sorry.
>
> Can anyone tell me what happens when I
On Mon, Oct 24, 2022 at 09:26:14PM +, Per Nordlöw via Digitalmars-d-learn
wrote:
> What property of a container (type) `T` enables iteration as
>
> ```d
> foreach (k, v; T.init)
> {
> ...
> }
> ```
>
> ? I thought it sufficed to define `T.byKeyValue` but its presence seem
> to have no
On Sun, Oct 23, 2022 at 01:32:44PM +, matheus via Digitalmars-d-learn wrote:
> Hi,
>
> I have a design question and I'd like to hear some advice. Let's say
> that I want to create a method to sort an array:
>
> arr.sort(asc);
>
> I think usually this would usually return a new set of
On Fri, Oct 21, 2022 at 04:32:17PM +, Hipreme via Digitalmars-d-learn wrote:
> Hey guys, I have been complaining a lot of time right now from D
> compilation speed at least for my project.
>
> I have:
> - Underused CTFE
> - Underused Templates
> - Avoided importing standard libraries
> -
On Wed, Oct 19, 2022 at 01:15:37AM +, Adam D Ruppe via Digitalmars-d-learn
wrote:
> On Wednesday, 19 October 2022 at 00:57:31 UTC, H. S. Teoh wrote:
> > Has it really been implemented? I tested the latest git master, the
> > following code doesn't compile:
>
> it only applies to types, not
On Sat, Oct 15, 2022 at 12:47:02AM +, Mike Parker via Digitalmars-d-learn
wrote:
> On Friday, 14 October 2022 at 22:17:52 UTC, H. S. Teoh wrote:
>
> > Given that this particular trap crops up regularly, perhaps some
> > sort of warning ought to be added. Once the @nodiscard DIP is
> >
On Fri, Oct 14, 2022 at 09:51:54PM +, WhatMeWorry via Digitalmars-d-learn
wrote:
>
> I lost about a half an hour troubleshooting some code of mine which as it
> turned out to be resolved with just one line.
>
>
> // paths.remove(i); // compiles fine but does nothing
>
> paths =
On Wed, Oct 05, 2022 at 04:57:57PM +, Paul via Digitalmars-d-learn wrote:
>I'm sure I'm making this more difficult than it needs to be. I'm
> trying to convert an integer to a dchar. The solution below works but
> seems like overkill.
>
> dstring dstrValue = to!dstring(5);
>
On Mon, Oct 03, 2022 at 05:38:25PM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
> Good catch but I think what we want is a copy of the front element, at
> least for InputRanges (.save does not work for File.byLine :/).
One of the things we need to settle in Phobos v2 is what to do
On Sat, Oct 01, 2022 at 01:20:08PM +, realhet via Digitalmars-d-learn wrote:
> Hello,
>
> I just wanted to optimize a byte -> index lookup, by using a 256
> element table instead of using [1, 2, 3].countUntil(x) and I was
> amazed what I've found.
> My solution lookup[x] was not faster at
On Sat, Sep 17, 2022 at 12:19:16AM +, frame via Digitalmars-d-learn wrote:
> On Friday, 16 September 2022 at 23:06:35 UTC, H. S. Teoh wrote:
>
> > Basically, if you pass something to .fun by value, then that value
> > must be destroyed by .fun once it's ready to return. So if the
> > value
On Fri, Sep 16, 2022 at 10:43:43PM +, frame via Digitalmars-d-learn wrote:
> ```d
> import std.variant;
>
> // error: destructor `std.variant.VariantN!32LU.VariantN.~this` is not
> `nothrow`
> void fun(Variant v) nothrow
> {
>
> }
>
> void main()
> {
>fun(Variant());
> }
> ```
>
> A
On Mon, Sep 12, 2022 at 02:29:58PM -0400, Steven Schveighoffer via
Digitalmars-d-learn wrote:
[...]
> If your intent is to *enforce* pure functions only, then that's what
> you do. If your intent instead is to ensure that given proper
> parameters, the function will be pure, then the answer is
On Mon, Sep 12, 2022 at 10:08:29AM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
> What I meant was
>
> - if I put 'pure' etc. on my templatized code,
>
> - and then tested with a 'pure' unittest,
>
> I wouldn't know that the gratuitous use of my 'pure' on the member
> function was
On Mon, Sep 12, 2022 at 09:14:42AM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
> struct Foo(R) {
> R r;
> int i;
>
> bool empty() @nogc nothrow pure @safe scope {
> return r.empty;
> }
>
> auto front() @nogc nothrow pure @safe scope {
> return
On Sat, Sep 10, 2022 at 04:59:50PM +, Injeckt via Digitalmars-d-learn wrote:
> I'm trying use classes in my project, but when i'm try inherit class,
> I get error:
>
> Error: import `Server.Console` is used as a type
[...]
Don't name the module the same thing as the class. Rename it
On Wed, Sep 07, 2022 at 06:11:14PM +, Injeckt via Digitalmars-d-learn wrote:
> I need to include this Ws2tcpip.h header file to my project. How can I
> do this? It's all because I need inet_ntop function from this header
> file.
If that's the only function you need, you can just copy the
On Fri, Aug 12, 2022 at 12:12:13AM +, Adam D Ruppe via Digitalmars-d-learn
wrote:
> On Thursday, 11 August 2022 at 23:50:58 UTC, H. S. Teoh wrote:
> > I think the OP's idea is somewhat different: adding contextual
> > information to a propagating exception that the throwing code may
> > not
On Thu, Aug 11, 2022 at 11:06:45PM +, Adam D Ruppe via Digitalmars-d-learn
wrote:
> You might find my recent blog post interesting too:
>
> http://dpldocs.info/this-week-in-d/Blog.Posted_2022_08_01.html#exception-template-concept
>
> and a draft of some more concepts:
>
On Sat, Aug 06, 2022 at 03:37:32PM +, pascal111 via Digitalmars-d-learn
wrote:
> On Friday, 5 August 2022 at 04:05:08 UTC, Salih Dincer wrote:
> > On Thursday, 4 August 2022 at 22:54:42 UTC, pascal111 wrote:
> > >
> > > I didn't notice that all what we needs to pop a range forward is
> > >
On Fri, Aug 05, 2022 at 08:06:00AM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
> [...] I realized that the following fails with a RangeError:
>
> void main() {
> auto arr = [1, 2, 3];
> arr[0..$-1] = arr[1..$];// <-- Runtime error
> }
>
> I suspect the length of the array is
On Fri, Aug 05, 2022 at 02:23:15PM +, Ruby The Roobster via
Digitalmars-d-learn wrote:
> On Friday, 5 August 2022 at 14:11:09 UTC, H. S. Teoh wrote:
> > On Fri, Aug 05, 2022 at 01:56:40PM +, Ruby The Roobster via
> > Digitalmars-d-learn wrote: [...]
> > > public import dutils.math.core;
>
On Fri, Aug 05, 2022 at 01:56:40PM +, Ruby The Roobster via
Digitalmars-d-learn wrote:
[...]
> public import dutils.math.core;
Is the imported module available anywhere? I'm trying to run your code
sample to determine what's going on, but it's not compiling because you
didn't post the code
On Thu, Aug 04, 2022 at 11:52:48PM +, pascal111 via Digitalmars-d-learn
wrote:
> On Thursday, 4 August 2022 at 21:35:37 UTC, Adam D Ruppe wrote:
> > On Thursday, 4 August 2022 at 21:15:39 UTC, pascal111 wrote:
> > > > https://github.com/adamdruppe/arsd/blob/master/terminal.d
> > >
> > > How
On Thu, Aug 04, 2022 at 07:22:04AM +, Domain via Digitalmars-d-learn wrote:
> On Wednesday, 3 August 2022 at 12:27:32 UTC, frame wrote:
> > On Wednesday, 3 August 2022 at 03:36:55 UTC, Domain wrote:
> > > I want to find out all public functions in all modules in a package.
> > > Can I do that
On Thu, Aug 04, 2022 at 12:45:44AM +, Ruby The Roobster via
Digitalmars-d-learn wrote:
> How exactly can one store the string representation of a BigInt? The
> seemingly obvious
>
> ```d
> //...
> dchar[] ret; //dchar[] is necessary for my project
> //Assume that val is a BigInt with a
On Thu, Aug 04, 2022 at 12:35:55AM +, Alex Burton via Digitalmars-d-learn
wrote:
> Hi,
> I want to use MmFile to manage memory mapped files. I want multiple
> processes to be able to read in many files using the virtual memory
> system to page them in and reuse the memory.
>
> If I read the
On Wed, Aug 03, 2022 at 04:28:57AM +, anonymouse via Digitalmars-d-learn
wrote:
> How do I go about tracking down what's causing the following error:
>
> ```
> Undefined symbols for architecture x86_64:
> "__D3std8internal6memory12__ModuleInfoZ", referenced from:
>
On Tue, Aug 02, 2022 at 11:10:27AM +, Alexander Zhirov via
Digitalmars-d-learn wrote:
[...]
> ```d
> auto result = db.query("select tcxs.settings_file as dbfile from
> amts.t_client_xrdp_settings tcxs where tcxs.pid_client = ?", id);
> ubyte[] bytes = cast(ubyte[])result.front()["dbfile"];
>
On Fri, Jul 29, 2022 at 10:32:11PM +, pascal111 via Digitalmars-d-learn
wrote:
[...]
> I want searching for value 54 in array y "54.among(y).writeln;", but
> it seems compiler complaints because the data type is "int[]", so I
> tried to convert "y" to "uint[]".
You're using the wrong
On Fri, Jul 29, 2022 at 09:56:20PM +, Andrey Zherikov via
Digitalmars-d-learn wrote:
> In the example below `func` changes its `const*` argument. Does this
> violates D's constness?
>
> ```d
> import std;
>
> struct S
> {
> string s;
>
> void delegate(string s) update;
> }
>
>
On Thu, Jul 28, 2022 at 09:03:55PM +, pascal111 via Digitalmars-d-learn
wrote:
> On Thursday, 28 July 2022 at 19:37:31 UTC, rikki cattermole wrote:
[...]
> > foreach(value; input.splitWhen!((a, b) => delimiters.canFind(b))) {
> > writeln(value);
> > }
> > }
> > ```
>
> From
On Thu, Jul 28, 2022 at 04:45:55PM +, pascal111 via Digitalmars-d-learn
wrote:
> On Thursday, 28 July 2022 at 16:37:35 UTC, frame wrote:
> > On Thursday, 28 July 2022 at 16:17:16 UTC, pascal111 wrote:
> >
> > > My friend, there is a wide deep secret world for hackers. We have
> > > no any
On Thu, Jul 28, 2022 at 03:10:19PM +, pascal111 via Digitalmars-d-learn
wrote:
> On Thursday, 28 July 2022 at 15:03:34 UTC, H. S. Teoh wrote:
> > On Thu, Jul 28, 2022 at 02:30:38PM +, pascal111 via
> > Digitalmars-d-learn wrote: [...]
> > > Of-course D has a built in "sgn" function, but I
On Thu, Jul 28, 2022 at 02:30:38PM +, pascal111 via Digitalmars-d-learn
wrote:
[...]
> Of-course D has a built in "sgn" function, but I like to do it with my
> hands to be sure of code, I'm some doubtful and don't trust alien
> works.
Just use the source, Luke! Phobos is open source for a
On Mon, Jul 25, 2022 at 05:30:14PM +, pascal111 via Digitalmars-d-learn
wrote:
[...]
> int main(string[] args)
> {
>
>
> const(char)[] ch1 = "Hello World!";
> char[] ch2="Hello World!".dup;
>
> const(char) *p1;
> char *p2;
>
> ch2~="\0";
>
>
On Fri, Jul 22, 2022 at 04:50:44PM +, Ben Jones via Digitalmars-d-learn
wrote:
> I'm looking to store a pointer to one of 2 unrelated (no inheritance
> relationship) classes and use the LSb to track which type I have. Is
> this going to cause any problems with the GC? For one of the classes
On Tue, Jul 12, 2022 at 07:55:46PM +, ag0aep6g via Digitalmars-d-learn
wrote:
> On Tuesday, 12 July 2022 at 19:02:01 UTC, user1234 wrote:
> > On Tuesday, 12 July 2022 at 16:40:38 UTC, H. S. Teoh wrote:
> [...]
> > > Do not rely on this, however;
> >
> > Absolutely. I'd like to add:
On Tue, Jul 12, 2022 at 04:27:44PM +, Antonio via Digitalmars-d-learn wrote:
> It works
>
> ```d
> void main()
> {
>assert(null=="");
> }
> ```
>
> why?
Because an empty string is, by default, represented by an empty slice of
the null pointer.
Do not rely on this, however; it's
On Tue, Jul 12, 2022 at 01:56:11PM +, rempas via Digitalmars-d-learn wrote:
> On Tuesday, 12 July 2022 at 13:37:49 UTC, ag0aep6g wrote:
> >
> > static if (is(typeof(obj) == Test!T, T)) { printf("YES!!!\n"); }
>
> Haah? Ok, what does this work anyway? I thought you needed
>
On Tue, Jun 21, 2022 at 06:28:14PM +, Paul Backus via Digitalmars-d-learn
wrote:
> On Tuesday, 21 June 2022 at 17:33:46 UTC, H. S. Teoh wrote:
> >
> > Does the language allow you to declare a @system delegate inside
> > @safe code?
>
> Yes. This compiles:
>
> void main() @safe
> {
On Tue, Jun 21, 2022 at 01:29:47PM -0400, Steven Schveighoffer via
Digitalmars-d-learn wrote:
> On 6/21/22 1:17 PM, H. S. Teoh wrote:
[...]
> > This is why I've proposed in the past that @safe functions should be
> > allowed to call @system delegates that they receive as arguments. The
> >
On Tue, Jun 21, 2022 at 04:47:44PM +, Antonio via Digitalmars-d-learn wrote:
> On Tuesday, 21 June 2022 at 16:20:32 UTC, Antonio wrote:
>
> > My code starts to be a @safe/@trusted mess (because external
> > libraries). The only solution I have is to "wrap" them or to trust
> > all code by
On Fri, Jun 10, 2022 at 08:08:45AM +, Chris Katko via Digitalmars-d-learn
wrote:
> Is it somehow possible to use a struct as a [multidimensional] array index:
>
> D
>
> struct indexedPair
> {
> size_t x, y;
> }
>
> bool isMapPassable[100][100];
> auto p = indexedPair(50, 50);
>
>
On Mon, Jun 06, 2022 at 10:18:08PM +, mw via Digitalmars-d-learn wrote:
> Hi,
>
> Suppose I have this code:
>
> ```
> class GCAllocated {
> float[] data;
>
> this() {
> // non-gc-allocated field
> this.data = cast(float[])(core.stdc.stdlib.malloc(nBytes)[0 .. nBytes]);
> }
> }
On Wed, May 18, 2022 at 08:05:05PM +, HuskyNator via Digitalmars-d-learn
wrote:
[...]
> ```d
> module app;
> import std.stdio;
>
> struct A {
> float[1] vec;
> this(float[1] n) {
> this.vec = n;
> }
> }
>
> void main(string[] args) {
> A c = A([50.0f]);
On Wed, May 18, 2022 at 02:35:00PM -0400, Steven Schveighoffer via
Digitalmars-d-learn wrote:
[...]
> No. Class destructors are for cleaning up non-GC resources. As long as
> you stick to those, you can safely run them.
>
> Structs that get put into classes have to run their destructors
>
On Wed, May 18, 2022 at 11:02:01AM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
> HORROR:
>
> Now, a big one that I've just realized.
>
> - The two guidelines above (the "don't touch class members" one and
> the "don't allocate" one) miss an important fact that they apply
>
On Mon, May 16, 2022 at 05:02:57PM +, IGotD- via Digitalmars-d-learn wrote:
> On Sunday, 15 May 2022 at 16:08:01 UTC, Mike Parker wrote:
> >
> > `scope` in a class variable declaration will cause it to the class
> > to be allocated on the stack.
> >
>
> Common practice is that a class has
On Mon, May 16, 2022 at 04:00:12AM +, cc via Digitalmars-d-learn wrote:
> On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
> > What are you stuck at? What was the most difficult features to
> > understand? etc.
> >
> > To make it more meaningful, what is your experience with
On Sun, May 15, 2022 at 08:05:05PM +, Kevin Bailey via Digitalmars-d-learn
wrote:
[...]
> But I asked a different question: Why can't I put a class object on
> the stack? What's the danger?
[...]
You can. Use core.lifetime.emplace.
Though even there, there's the theoretical problem of stack
On Sat, May 14, 2022 at 04:39:33AM +, zjh via Digitalmars-d-learn wrote:
> On Saturday, 14 May 2022 at 04:31:48 UTC, zjh wrote:
>
> > Likewise, each post could add something like `votes` ,
>
> Or something like all kinds of `tags` such as
> `range/fiber/commandline/auto ref/in/...`.
>
>
On Fri, May 13, 2022 at 06:29:54PM +, Adam D Ruppe via Digitalmars-d-learn
wrote:
[...]
> Yeah, I used to be pro-TLS by default, then got bit by it several
> times and moved to the fence, and now I'm anti.
>
> Data races aren't actually prevented by it (maybe forcing you to
> specify shared
On Thu, May 12, 2022 at 11:45:47PM +, Guillaume Piolat via
Digitalmars-d-learn wrote:
> On Thursday, 12 May 2022 at 17:34:30 UTC, H. S. Teoh wrote:
> >
> > Why is TLS by default a problem?
> >
> > It's not really for optimization, AIUI, it's more for thread safety:
> > module-global state
On Fri, May 13, 2022 at 03:43:09PM +, Johan via Digitalmars-d-learn wrote:
> On Thursday, 12 May 2022 at 21:58:33 UTC, Ali Çehreli wrote:
> > I am considering proposing a presentation for DConf 2022.
> >
> > Would a "Back to Basics" style presentation be interesting? If, so
> > what exact
101 - 200 of 1571 matches
Mail list logo