Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 13:30:27 UTC, zjh wrote: Could you explain more detail? It is just normal code with a normal name. The fact there's another variable with the same name doesn't change anything.

Re: Scope of enum

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 13:21:35 UTC, DLearner wrote: Is there a 'D' way of avoiding the issue? Pass the size as a parameter to the thing instead of trying to combine things. like mixin template Thing(size_t size) { ubyte[size] pool; } and where you want it like mixin

Re: mixin template's alias parameter ... ignored ?

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 05:20:49 UTC, someone wrote: ```d mixin template templateUGC ( typeStringUTF, alias lstrStructureID ) { public struct lstrStructureID { typeStringUTF whatever; } This creates a struct with teh literal name `lstrStructureID`. Just like any

Re: Scope of enum

2021-07-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 11 July 2021 at 12:37:20 UTC, DLearner wrote: C:\Users\SoftDev\Documents\BDM\D\Examples\CTFE\T2>type k_mod.d // k_mod.d ubyte[MemSiz] MemPool; You didn't import the other module here. D's imports aren't like C's includes. Each module is independent and can only see what it

Re: Error: Outside Unicode code space

2021-07-08 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 9 July 2021 at 03:09:52 UTC, Tony wrote: The editor I am using (Code::Blocks) displays the characters just fine. So it seems that the error message should be "Error: Outside the ASCII code space". D supports stuff outside the ASCII code space just fine. Are you sure the file is

Re: Trivial simple OpenGl working example

2021-07-08 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 8 July 2021 at 13:51:51 UTC, Виталий Фадеев wrote: It may be based on any library: SDL, GLFW, Derelict, etc. my library http://arsd-official.dpldocs.info/arsd.simpledisplay.html#topic-modern-opengl arsd-official:simpledisplay dependency on dub, or just download color.d and

Re: How to disable assigning a value to a property?

2021-07-06 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 6 July 2021 at 10:06:11 UTC, Jack Applegame wrote: How to disable `register.clock = 10;` You don't. The language always allows `a = b;` to be rewritten as `a(b);`. Best you can do is use different types for the two arguments. Maybe clock could take a struct Clock { int x; } or

Re: Are D classes proper reference types?

2021-06-24 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 24 June 2021 at 07:28:56 UTC, kinke wrote: *scope* classes are deprecated (I don't think I've ever seen one); I used it for my database thing where it is supposed to be destroyed reliably but also uses runtime polymorphism. I now suggest people just stick `scope(exit)

Re: List of Dynamic Arrays

2021-06-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 17 June 2021 at 15:57:46 UTC, Justin Choi wrote: I want to write something like `DList!int[]()` DList!(int[])() ?

Re: Class member initialization with new points to a single instance?

2021-06-09 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 9 June 2021 at 17:56:24 UTC, Gregor Mückl wrote: class Bar { Foo foo = new Foo(); } This is a static initialization The assert fails. This is completely surprising to me. Is this actually expected? Yes, it is expected if you are familiar with the spec. All member = x

Re: regarding what seems (to me) unnecessary casts on integer expressions

2021-06-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 June 2021 at 02:38:50 UTC, someone wrote: Furthermore, if, **at least**, there was a way to clearly state what is short (eg 1S a la 1L) things will improve a lot That actually doesn't matter. The compiler actually will automatically type it to the most narrow thing it fits. The

Re: regarding what seems (to me) unnecessary casts on integer expressions

2021-06-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 June 2021 at 01:46:45 UTC, someone wrote: What's the point of declaring, for instance ushort's if then nothing will treat them as ushort's and I have to manually cast() everything to ushort() all the time ? Yeah, it totally sucks. D inherited a silly rule from C - the promote

Re: Is it possible to set function attributes conditionally?

2021-06-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 4 June 2021 at 11:33:32 UTC, wjoe wrote: This is a contrived example. In reality I would use this with custom array, hash map and other container implementations so I could use them in @nogc territory by just switching out the allocator. If they are templates, just don't specify

Re: Question about initialization

2021-06-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 4 June 2021 at 11:27:05 UTC, seany wrote: In my untrained eye, this seems haphazard. One requires the use of the new keyword It doesn't. T[] a; just works. it is an array of length 0.

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 22:39:08 UTC, Ola Fosheim Grøstad wrote: My understanding is that dropping OS icons onto the web view is problematic You have to subscribe to the particular content type so it doesn't always work but it is totally doable. You can play with it using

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 21:47:38 UTC, Ola Fosheim Grøstad wrote: Right now, drag-and-drop is not as easily supported in browser UIs though. That is an argument for using native UI. eh web drag and drop isn't half bad at all. Have you ever used it? Note: Many simple GUI toolkits are

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 03:36:00 UTC, someone wrote: On Sunday, 30 May 2021 at 07:03:38 UTC, Chris Piker wrote: Of the 107 forks of dlangui last seen on github ... I can't believe it. What a waste of time/resources. It is like if I forked MATE, changed the title, made 10/20/or-so changes

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 05:26:47 UTC, Mike Parker wrote: But have you actually investigated it? It's being actively maintained. https://github.com/d-widget-toolkit/dwt Yeah, DWT is solidly OK. I'd pick it over gtkd if you wanted to target Windows since it doesn't use gtk there.

Re: How to compile Phobos with other D code to create a shared library?

2021-05-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 31 May 2021 at 21:46:09 UTC, data pulverizer wrote: Something interesting is using arrays. I can see that if you instantiate an array within the D function using `new`, for instance Passing one of those to a C function is iffy anyway because the C function can hide it from the

Re: Naming issue importing different function overloads

2021-05-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 30 May 2021 at 18:42:34 UTC, data pulverizer wrote: I wonder if it is a purposeful design It is by design: https://dlang.org/articles/hijack.html Basically the idea behind it is to make sure that a change in a lib you import doesn't change your existing code without you realizing

Re: How long does the context of a delegate exist?

2021-05-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 30 May 2021 at 09:39:28 UTC, cc wrote: Is there any way to enforce at compile time that we're not accidentally allocating when creating a delegate, other than being carefully aware of what variables are referenced inside the body? Use `function` instead of `delegate`. Then it

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 29 May 2021 at 10:51:47 UTC, btiffin wrote: Will politely disagree about 1 or 2 can't do by themselves... Yeah, yeah they can. Well, I've actually done it. My minigui has its quirks I'm slowly working through, but it clearly isn't impossible.

Re: DIP 1036--String Interpolation Tuple Literals--Has Been Withdrawn

2021-05-27 Thread Adam D. Ruppe via Digitalmars-d-announce
On Thursday, 27 May 2021 at 20:42:11 UTC, M.M. wrote: I assume that you, Adam and Steven, hold the new (YAI)DIP in high regards. Is that right? Yeah, there's a few small tweaks I'd make (I opened an issue on the repo with them), but I'm pretty happy with it and simplifying the goals like it

Re: How long does the context of a delegate exist?

2021-05-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 May 2021 at 20:44:21 UTC, frame wrote: Did you mean to add the delegate as GC root or the data? The delegate.ptr property.

Re: How long does the context of a delegate exist?

2021-05-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 May 2021 at 12:59:02 UTC, frame wrote: But what about the data used in the context of the delegate? If the delegate is created by the GC and stored it will still be managed by the GC, along with its captured vars. As long as the GC can see the delegate in your example you

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-05-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 May 2021 at 01:17:44 UTC, someone wrote: - like a simple classical UI: favored over any modern one: My minigui is a thing of beauty. Behold: http://arsdnet.net/minigui-linux.png http://arsdnet.net/minigui-sprite.png its docs:

Re: How does inheritance and vtables work wrt. C++ and interop with D? Fns w/ Multiple-inheritance args impossible to bind to?

2021-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 25 May 2021 at 17:52:14 UTC, Gavin Ray wrote: void takesADerived(Derived derived); extern class Derived : Base1, Base2 Like I said in chat, these are NOT the same thing. The C++ Derived is a *sibling* class, not a parent, child, nor binding to the D Derived. All your

Re: Formatted output not on screen but in a string

2021-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 21 May 2021 at 22:37:34 UTC, Alain De Vos wrote: Next code format a string and prints it. But I want the formatted string stored in a string ``` //Decimal place separator %, writefln!"%,s"(123456789); //123,456,789 ``` std.format.format

Re: State of D for webassembly

2021-05-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 May 2021 at 20:38:12 UTC, Chris Piker wrote: What is the general state of support for GC dependent D-code running as webassembly? If the runtime is not ready that's okay, just wanted to inquire about the state of things. There is a partial port of full runtime but it is still

Re: Encryption

2021-05-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 May 2021 at 16:54:18 UTC, noid wrote: Hi! I am pretty new on Dlang and I wanted to make a small password manager that used some sort of encryption on a file (for example AES256) and save a password to decrypt it later, so you can copy the password. I haven't done this

Re: property functions

2021-05-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 May 2021 at 14:56:21 UTC, Steven Schveighoffer wrote: It used to be required, but we removed that requirement a long time ago. yeah i remember ElementType required it last time i checked but that was a while ago indeed it is all fixed now

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 May 2021 at 00:27:01 UTC, SealabJaster wrote: I've opened a PR (https://github.com/dlang/dmd/pull/12526) with a super hacked together proof-of-concept. oh very good! I was going to add something similar to my own todo list but who knows when I'd get around to it. This kind of

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 22:17:16 UTC, Chris Piker wrote: It seems there's a broken symmetry in compiler error reporting for the following, ostensibly identical, cases: Oh yes, I completely agree with you. Sometimes error messages even use the name but it is from a different module so it is

Re: property functions

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 15:12:25 UTC, Nick wrote: Is this warning still valid? The @property thing doesn't do much. All it does is change typeof(a.prop) from function over to the return value of the function. (Which actually makes it required for the range empty and front things!) But

Re: DMC + Win32Api: Error: undefined identifier 'SetDCBrushColor'

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 14:51:56 UTC, Marcone wrote: Error: undefined identifier 'SetDCBrushColor' Did you include gdi32.lib on the command line?

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 12:54:19 UTC, Chris Piker wrote: a = b; // Lambdas as arguments instead of types works Wait a sec, when you do the ```d auto a = S!(a => a*2)(); ``` That's not actually passing a type. That's passing the (hidden) name of a on-the-spot-created function template

Re: struct destructor

2021-05-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 16 May 2021 at 08:04:06 UTC, cc wrote: If the goal is to absolutely squeeze the GC back down after using new or dynamic arrays, I find destroy + GC.free often fails to do the trick (e.g. GC.stats.usedSize remains high). destroy + GC.free has a quirk - GC.free only works on what

Re: struct destructor

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 17:55:17 UTC, Alain De Vos wrote: Feature request, a function old which does the opposite of new, allowing deterministic,real-time behavior and memory conservation. You're best off doing malloc+free if you want complete control though.

Re: struct destructor

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 18:15:24 UTC, Dennis wrote: On Saturday, 15 May 2021 at 17:55:17 UTC, Alain De Vos wrote: Feature request, a function old which does the opposite of new, allowing deterministic,real-time behavior and memory conservation. You can use

Re: Recommendations on avoiding range pipeline type hell

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 13:46:57 UTC, Chris Piker wrote: I'm trying to do that, but range3 and range2 are written by me not a Phobos wizard, and there's a whole library of template functions a person needs to learn to make their own pipelines. For example: Phobos has plenty of design

Re: struct destructor

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 16:52:10 UTC, Alain De Vos wrote: When I do a "new" in a struct constructor to assign to a member variable of this struct, what do i write in the same struct destructor to free the memory ? If you used `new` the garbage collector is responsible for it.

Re: Scope of import

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 11:46:49 UTC, Dennis wrote: You can do `dmd -i -run main.d` Yeah but that's weird with how it handles arguments and without the compilation cache it gets really annoying to use.

Re: Recommendations on avoiding range pipeline type hell

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 11:25:10 UTC, Chris Piker wrote: Then the type definition of mega_range is something in the order of: The idea is you aren't supposed to care what the type is, just what attributes it has, e.g., can be indexed, or can be assigned, etc. You'd want to do it all in

Re: Scope of import

2021-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 15 May 2021 at 07:15:51 UTC, DLearner wrote: rdmd main.d rdmd sucks, it runs the compiler twice and get the list of imports and even then it might not see them all. Just use dmd -i main.d instead. It will be about 2x faster and more reliable. The downside differences though:

Re: Filter for opDispatch?

2021-05-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 14 May 2021 at 22:39:29 UTC, frame wrote: - how can I tell the compiler that I do not want to handle some calls? Put a template constraint on it. `void opDispatch(string s)() if(s == "whatever")` or minimally like `if(s != "popFront")` This kind of thing is why I always put

Re: CalderaD - SDL2 Vulkan renderer for windows, linux, and android

2021-05-14 Thread Adam D. Ruppe via Digitalmars-d-announce
On Friday, 14 May 2021 at 17:38:54 UTC, Danny Arends wrote: Hmm, things gotta have a license, why not GPL would CC0 be better? is attribution and sharing code so weird ? GPL is a perfectly fine license. If people don't want to use it because of that, their loss, not your problem.

Re: How use Predicate (alias pred = "a*b")?

2021-05-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 May 2021 at 21:30:43 UTC, Marcone wrote: template foo(alias pred = "a*b"){ void foo(int x, int y){ writeln(x.unaryFun!pred); First, you really shouldn't use these at all. instead of a string, just pass an actual function to the thing as the predicate.

Re: Is inc function part of the library ?

2021-05-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 May 2021 at 17:48:34 UTC, kdevel wrote: Then D's pure does not match up with WP's definition [1] of pure, at least not Yeah, D's pure is actually useful without being a huge hassle. Makes it into a useful building block that can be used inside other scenarios than the purely

Re: Passing a byLine as an argument to InputRange

2021-05-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 May 2021 at 17:07:51 UTC, Jeff wrote: I have a class where I'd like to supply it with an InputRange!string. Yet, for the life of me I can't seem to pass to it a File.byLine, even though the documentation states it's an InputRange. byLine is not a range of string. It is a

Re: Is inc function part of the library ?

2021-05-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 May 2021 at 13:30:29 UTC, Alain De Vos wrote: Or have I a wrong understanding of pure or the compiler. pure means it doesn't depend on any mutable info outside its arguments. You are only working on the arguments there so it is ok.

Re: Shutdown signals

2021-05-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 10 May 2021 at 23:35:06 UTC, Tim wrote: I can't find that in the docs, nor in dpldocs. Can you help out with this? dpldocs.info/signal it comes up as the second result. The C function you call from there (on linux anyway) is sigaction. A little copy/paste out of my terminal.d:

Re: Shutdown signals

2021-05-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 10 May 2021 at 23:20:47 UTC, Tim wrote: Hi all, How can I get a D program to detect something a keyboard interrupt so I shut things down in a specific way? import core.sys.posix.signal; then you can use the same functions as C to set signal handlers.

Re: Templated class requires values even though having default value

2021-05-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 9 May 2021 at 10:53:49 UTC, tcak wrote: The "dim" template parameter has a default value of 1 already. Why does it still force me to give a value? It doesn't, but it does require you to instantiate the template. You can do `OpenClKernel!()` to use the default value. But without

Re: Without multiples inheritance, how is this done?

2021-05-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 May 2021 at 18:33:35 UTC, Jack wrote: ```d abstract class DRY : Base { this(int n) { this.n = n; } override int f() { super.doSomething(); return n; } private int n; } ``` You can change that from abstract class to `mixin

Re: What does dot before method name mean?

2021-05-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 May 2021 at 02:29:18 UTC, Stephen Miller wrote: Is there an easy way to know what the system functions are? they are imported. Windows uses winsock: http://phobos.dpldocs.info/source/std.socket.d.html#L50 posix uses their socket thing:

Re: What does dot before method name mean?

2021-05-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 May 2021 at 01:45:49 UTC, Stephen Miller wrote: I am writing a tcp proxy server and I noticed that when a socket is in non-blocking mode, it returns -1 if it doesn't receive data, as opposed to 0. It sets the `wouldHaveBlocked` flag in that case returning -1. 0 always means

Re: class grammar

2021-05-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 May 2021 at 18:07:45 UTC, Nick wrote: The class grammar, as defined in the D language specification ([Classes](https://dlang.org/spec/grammar.html#classes)), seems to imply that a class can inherit from a fundamental type. Explicitly, the specification says that a 'SuperClass' is

Re: Can the DMC completely replace the C or C ++ compiler?

2021-05-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 May 2021 at 20:21:32 UTC, Marcone wrote: Is it compatible with C++ 17 or 20? No, it is based on the 1998 standard.

Re: Can the DMC completely replace the C or C ++ compiler?

2021-05-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 May 2021 at 19:59:01 UTC, Marcone wrote: Well, I am writing a C++ program and compiling with DMC Digital Mars, and the program is running normally. Can the DMC completely replace the C or C ++ compiler? It IS a C and C++ compiler.

Re: OutOfMemoryError in D DLL appending to module-level array

2021-05-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 2 May 2021 at 02:34:41 UTC, cc wrote: which seems to fix it, but I'm not entirely sure what's going on, if this is expected behavior, if that's the correct way to handle it, and so on. Oh I've been working on this the last couple weeks and having a hard time reproducing outside

Re: Deriving a D-class from a CPP-class

2021-04-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 19:46:00 UTC, Alain De Vos wrote: Following code produces a linker error. d: error: undefined symbol: wxApp::OnInit() ``` extern(C++) {class wxApp { public: bool OnInit(); //virtual

Re: (Maybe) Strange Behaviour of Field Initialization

2021-04-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 15:09:36 UTC, eXodiquas wrote: ```d class Particle : Drawable { CircleShape shape = new CircleShape(5); This `new` is actually run at compile time, so every instance of Particle refers to the same instance of CircleShape (unless you rebind it).

Re: DIP1000 and immutable

2021-04-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 27 April 2021 at 14:28:12 UTC, jmh530 wrote: However, should it ever matter if you escape an immutable? Your example is a pretty clear case of use-after-free if gloin actually did escape the reference and kept it after main returned. I tried basically the same thing in Rust and

Re: Visual D showing weird errors

2021-04-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 April 2021 at 08:00:08 UTC, Raimondo Mancino wrote: C:\D\dmd2\src\druntime\import\core\sys\windows\dll.d: \object.d(18): can only `*` a pointer, not a `typeof(null)` Do you have a separate object.d in your current directory? That can cause all kinds of weird errors. Otherwise

Re: win64 DLL stdout printing after main process completes

2021-04-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 April 2021 at 14:44:53 UTC, cc wrote: I run a D program through the basic cmd.exe, it runs with no stdout buffering. You'll find the same thing with C programs, since it is actually the C standard library that does this buffering rather than D. If it is writing to a character

Re: Suitability of D for a Crossplatform Graphical App

2021-04-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sun, Apr 25, 2021 at 08:10:17PM +, graw via Digitalmars-d-learn wrote: > A few years ago I know there was some efforts to get D building for android > with LDC and dlangui building for android. I don't know about dlangui, but I had success getting hello world working on android, including

Re: get type name from current class at compile time?

2021-04-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 25 April 2021 at 12:54:43 UTC, Jack wrote: I find out this later. I give up trying to get this in automatic way at compile time That's because the type might not be known at compile time at all, it might come from like a plugin loaded at run time and only ever accessed through the

Re: get type name from current class at compile time?

2021-04-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 25 April 2021 at 03:45:13 UTC, Jack wrote: that's better, thanks Imporant to remember that any compile time thing will be the static type. If someone does: Base a = new Derived(); a.something(); it will still show up as Base in the this template. The knowledge that it is

Re: String concatenation segmentation error

2021-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 23 April 2021 at 00:44:58 UTC, tcak wrote: As far as I see, it is not related to that array or indices at all. The question of where is to see if it was CTFE allocated or runtime allocated. I don't think it should make a difference here but idk. If there is no known situation

Re: String concatenation segmentation error

2021-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 22 April 2021 at 21:15:48 UTC, tcak wrote: "positions" array is defined as auto positions = new float[ 100 ]; So, I am 100% sure, it is not out of range. "ri*dim + 1" is not a big number at all. Oh and *where* is that positions variable defined?

Re: String concatenation segmentation error

2021-04-22 Thread Adam D. Ruppe via Digitalmars-d-learn
Are there any other threads in your program?

Re: win64 DLL stdout printing after main process completes

2021-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 19 April 2021 at 18:05:46 UTC, cc wrote: This seems to work if I flush after every printf or write in both main and the dll. I was under the impression they were supposed to share the same IO buffers though, is this not the case? Very little in D dlls right now are shared, so

Re: win64 DLL stdout printing after main process completes

2021-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 19 April 2021 at 14:55:03 UTC, cc wrote: https://wiki.dlang.org/Win32_DLLs_in_D I'm starting to think half that page should just be deleted... the version up top with the druntime dll_process_attach etc versions should really be used in all cases. And that gets even simpler too,

Re: ioctl to set mixer volume

2021-04-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 16 April 2021 at 17:50:13 UTC, Alain De Vos wrote: The following very simple low level C-function simply sets the mixer volume. How to convert this simple function to dlang ? ``` import core.stdc.config; import core.sys.posix.sys.ioctl; void mixer_setlevel_stereo(int mixfd,int

Re: How do I create classes dynamically?

2021-04-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 14 April 2021 at 20:38:16 UTC, Mario wrote: Maybe I am just too short in D, but I wanted to find out if it is possible to create classes dynamically. My problem is, I just don't know where to start reading. Maybe at mixin templates? What exactly do you mean? Your goal is

Re: Read X many bytes from File to address Y

2021-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 12:57:12 UTC, tcak wrote: Well, I have a struct, that is defined as a variable already. I want to read X bytes from the file (not Struct.sizeof bytes though), and read into the struct variable without any extra buffer. file.rawRead((cast(ubyte*) _struct)[0 ..

Re: Read X many bytes from File to address Y

2021-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 11:42:56 UTC, tcak wrote: There is rawRead, but it takes an array as parameter, which causes a dirty looking code with cast etc! What did you wrote? file.rawRead(address[0 .. desiredLength]) should do what you want.

Re: Don't allow to reassign, but content is editable

2021-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 12:28:25 UTC, tcak wrote: @property auto b(){ return a.ptr; } // this is a possibility, but results with overhead of calling. Also, b is not an array anymore, just int*. Why are you returning a.ptr instead of just a? If you return just a, it works fine for

Re: Windows Console and writing Unicode characters

2021-03-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 30 March 2021 at 08:31:02 UTC, Luhrel wrote: I have been used this trick in C++, so it might also work in D: If you follow through the link that's what I mention as being a bad idea and provide the code given as a more correct alternative. It changes a global (well to the

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-03-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 29 March 2021 at 19:06:33 UTC, Marcone wrote: Why can't I just use: import vibe.vibe; for import packages like Nim or Python? Why I still use DUB? I don't use dub. Just dmd -i after you set up the files in the right place. Not all libraries support that but I only use my own

Re: Windows Console and writing Unicode characters

2021-03-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 29 March 2021 at 02:12:57 UTC, Brad wrote: a custom implementation for writeln rather than use the one in stdout module (package?) that would mean any other functions from that package I would want to leverage I would need to include by name. You can still import std.stdio and use

Re: Cannot deduce function from argument type when single candidate

2021-03-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 29 March 2021 at 01:24:13 UTC, Preetpal wrote: writeln(isRandomAccessRange(arr)); Template arguments are passed by !(), not just (). I believe you must also pass `typeof(arr)` since isRandomAccessRange is only interested in types.

Re: How to update DUB online documentation?

2021-03-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 28 March 2021 at 17:59:49 UTC, Mark Lagodych wrote: But auto-generated online documentation and online code viewer show an outdated version (0.0.1). How to solve that? Click on the documentation page, then notice at the very bottom of the page, in small text, there's "Clear Cache".

Re: How to update terminal output?

2021-03-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 28 March 2021 at 17:13:02 UTC, Mark Lagodych wrote: Although some (all?) of that commands do not work in the Windows terminal. For instance, you can change background color ONLY using Windows API. Windows can support them all if you enable the setting. but yeah anything outside

Re: Why Throwable.message is not a property

2021-03-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 19:32:02 UTC, uranuz wrote: Seems that a problem with concatenation is because Throwable.message has const(char)[] type, but not string. This makes some inconvenience ;-) Yes, that's what I thought. The concat operation tends to give the most flexible type of

Re: Why Throwable.message is not a property

2021-03-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 17:46:27 UTC, uranuz wrote: Also because it is not a property in some contexts when I try to concatenate it with string without parentheses using "~" operator it fails Can you post some sample code that demonstrates this?

Re: Release D 2.096.0

2021-03-15 Thread Adam D. Ruppe via Digitalmars-d-announce
On Sunday, 14 March 2021 at 18:25:51 UTC, starcanopy wrote: int foo() { return 1; } int foo() => 1; I'm concerned that this feature will be in purgatory if its author becomes busy or forgets about it. (Barring another individual assuming proprietorship.) I wrote the implementation for that

Re: Is there an easy way to convert a C header to a D module?

2021-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 March 2021 at 02:43:01 UTC, Tim wrote: Seems pretty good. Does it work on c++ stuff too? I don't think so

Re: Is there an easy way to convert a C header to a D module?

2021-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 March 2021 at 01:53:31 UTC, Tim wrote: I'm needing to use a c/c++ library in a D program and I'm struggling with creating a binding as it seems like an enormous amount of regex modifications. Is there an existing program that can create most if not all of a binding for me?

Re: Workaround to "import" an exception from a DLL

2021-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 March 2021 at 12:27:17 UTC, evilrat wrote: The problem is that TypeInfo is not shared on Windows, which is actually roots deeper in the other problems with "sharing". Unfortunately I cannot provide you with details, but this situation is well known long standing issue. It isn't

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 13 March 2021 at 23:41:28 UTC, David wrote: So Excel complains that it can't load my library - presumably because libphobos2 and libdruntime are not in the sandbox.ly You *might* be able to compile with --link-defaultlib-shared=false to use the static phobos+druntime... but with

Re: Two functions with different args. Taking address of the one

2021-03-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 11 March 2021 at 12:26:07 UTC, Виталий Фадеев wrote: _processMouseKey = // <-- not works _processMouseMove = // <-- not works This *should* actually work. What type are those variables? struct MouseKeyEvent {} struct MouseMoveEvent{} void process( ref MouseKeyEvent

Re: Does is(f == function) work?

2021-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 9 March 2021 at 11:58:45 UTC, Andrey Zherikov wrote: Should it work for in this case as well? alias f = (){}; I actually don't know. The docs do say that function pointers work differently - they match `is(typeof(f) == return)` but it isn't clear if it would match == function.

Re: How to get number of parameters in lambda?

2021-03-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 9 March 2021 at 03:08:14 UTC, Paul Backus wrote: Yes, it's possible. For example: template fun(T) { It'd be nice if we could at least get the arity of a template, then perhaps speculatively instantiate it and reflect on the eponymous function then. (that's a lot of jargon lol

Re: Does is(f == function) work?

2021-03-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 9 March 2021 at 02:50:11 UTC, Andrey Zherikov wrote: writeln(is(f == function));// prints "false" try is(typeof(f) == function) it is kinda weird but that's the trick

Re: D's Continous Changing

2021-03-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 March 2021 at 15:54:37 UTC, Paul Backus wrote: The website is *supposed* to keep documentation for old versions around, and allow you to select them using the drop-down menu at the top-right: note that in some cases my website lets you pull old versions too:

Re: How can I tell if the give parameter can be run at compile time?

2021-03-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 1 March 2021 at 20:05:57 UTC, Jack wrote: int a; enum s = ""; // both return false but g(s) is expected to return true So the value must be known at compile time without any extra context. So that `a` variable might be changed somewhere else so compile time can't read or write it.

Re: Does reserve() preallocate for futher appends too?

2021-02-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 1 March 2021 at 03:07:19 UTC, Jack wrote: isn't clear for me if reserve() does preallocate memory so that that operator like arr ~= x can use previously allocate memory by reserve() or it's just used in slices like b = arr[x .. y]? Slicing never allocates memory. reserve extends

Re: How can I make this work?

2021-02-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 28 February 2021 at 07:05:27 UTC, Jack wrote: I'm using a windows callback function where the user-defined value is passed thought a LPARAM argument type. I'd like to pass my D array then access it from that callback function. How is the casting from LPARAM to my type array done in

Re: How can I get the variable name passed as parameter from within a function?

2021-02-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 February 2021 at 19:32:52 UTC, Jack wrote: I managed to do this with alias parameter in a template: this is the only way, it needs to be an alias template Also, can I short this template function somehow to syntax f!(a) omitting the g? rename g to f. If the function inside

<    1   2   3   4   5   6   7   8   9   10   >