Re: figure out where a particular template function is located

2020-06-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 20:28:24 UTC, Steven Schveighoffer wrote: Is there a way to figure this out from the call? The .mangleof the instance might help track it down since it should give you the module name as part of that mangle. Then go in there and start breaking things (or use the

Re: Some questions about strings

2020-06-21 Thread Adam D. Ruppe via Digitalmars-d-learn
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 string, there won't be another decoding/encoding done -- correct?

Re: Some questions about strings

2020-06-21 Thread Adam D. Ruppe via Digitalmars-d-learn
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 you can see the difference. - Are the characters of a string

Re: Passing a variable number of slices into a function

2020-06-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 June 2020 at 02:04:06 UTC, user1234 wrote: Maybe each slice has different type ? in some cases T[][]... will work better too. depends on the details here

Re: why cannot spawn function defined in unittest block {}?

2020-06-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 20 June 2020 at 17:43:42 UTC, mw wrote: the function defined in unittest become a delegate? how to work-around this? just add the keyword static to the functions

Re: Should a parser type be a struct or class?

2020-06-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 14:24:01 UTC, Stefan Koch wrote: Parser in dmd does even inherit from Lexer. why would a parser ever inherit from a lexer?

Re: Weird behavior with UDAs

2020-06-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 13 June 2020 at 12:55:36 UTC, realhet wrote: My first question is, how to avoid that error with A.i4? Why is there a difference between @UNIFORM and @UNIFORM(), do the first returns a type and the later returns a value? Basically yeah. a UDA in D is just whatever you write gets

Re: What is the current stage of @property ?

2020-06-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 10 June 2020 at 22:50:17 UTC, Paul Backus wrote: static assert(isInputRange!S); // passes isInputRange doesn't check it but others do. std.random.isSeedable requires @property on front for example. Some apparently test incorrectly too, like std.range.primitives.moveFront

Re: Metaprogramming with D

2020-06-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 8 June 2020 at 14:41:55 UTC, Jan Hönig wrote: What is the name of this `q` thing? It is just a string that looks like code.

Re: Mixin and imports

2020-06-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 8 June 2020 at 02:55:25 UTC, jmh530 wrote: In the code below, foo!fabs compiles without issue, but foo!"fabs" does not because the import is not available in the string mixin. Why do you even want foo!"fabs"? Usually when I see people having this problem it is actually a

Re: Control flushing to stdout... core.osthread.Thread + arsd.terminal

2020-06-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 June 2020 at 20:11:16 UTC, aberba wrote: Didn't come to mind to lookup from terminal docs. Thought it was a Dlang/OS problem. Yeah, the OS by itself rarely buffers output like this, but both the C library (on which std.stdio is built) and my Terminal object do (they do

Re: Control flushing to stdout... core.osthread.Thread + arsd.terminal

2020-06-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 June 2020 at 20:05:28 UTC, aberba wrote: Why was the initial decision to handle buffering that way in terminal? More buffering = more speed, it actually makes a surprisingly big difference sometimes, like you can notice the lag with your eyes alone as it prints in the more

Re: Control flushing to stdout... core.osthread.Thread + arsd.terminal

2020-06-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 June 2020 at 11:45:31 UTC, aberba wrote: How can I make Thread.sleep() only run AFTER "Wait, signing you in ..." is written (force flushed) to stdout? just use explicit `terminal.flush();` any time you want the output to appear immediately. Terminal does its own aggressive

Re: How to get the pointer of "this" ?

2020-05-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 11:35:23 UTC, Vinod K Chandran wrote: Okay, but uint is working perfectly. It won't if you use -m64.

Re: How to get the pointer of "this" ?

2020-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 May 2020 at 22:32:52 UTC, Vinod K Chandran wrote: What is an opCast ? operator overload of the cast function. if you didn't write one, you don't have to worry about this.

Re: How to get the pointer of "this" ?

2020-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 May 2020 at 22:31:00 UTC, Vinod K Chandran wrote: A dword is an unsigned, 32-bit unit of data. We can use uint in D. I have tried that too, but no luck. A DWORD_PTR is *not* the same as a uint. It is more like a size_t or void* depending on context.

Re: How to get the pointer of "this" ?

2020-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 May 2020 at 21:45:39 UTC, welkam wrote: Where is DWORD_PTR defined? it is a win32 thing. should be able to directly cast to it most the time if there is opCast on the class it needs another layer of helper function but without opCast it should just work

Re: alias this and initialisation

2020-05-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 May 2020 at 01:35:47 UTC, Danni Coy wrote: s = 8; // this works S s = 8 // but this does not? } alias this only applies if you already have an object. Construction is too soon. You can add a constructor to make that work though.

Re: Static assert triggered in struct constructor that shouldn't be called

2020-05-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 24 May 2020 at 21:34:53 UTC, jmh530 wrote: The following code results in the static assert in the constructor being triggered, even though I would have thought no constructor would have been called. static assert is triggered when the code is *compiled*, whether it is actually run

Re: How to use base class & child class as parameter in one function ?

2020-05-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 22 May 2020 at 20:04:24 UTC, Vinod K Chandran wrote: sampleList.Add(New Child(10.5)) Is this possible in D without casting ? Direct translation of this code works just fine in D.

Re: String interpolation

2020-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 May 2020 at 17:10:31 UTC, mw wrote: BTW, is the .idup must be there? It is discussed more in the github document but basically the proposed built-in syntax returns a generic builder thing which can make more than just strings. The idup specifically asks it to make a copy

Re: String interpolation

2020-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 May 2020 at 06:57:28 UTC, mw wrote: i.e how to write this 's'? gimme a like on the proposal to add to the language! https://github.com/dlang/DIPs/pull/186 If accepted, that would let you write i"stuff here".idup to get an interpolated string.

Re: How to allocate/free memory under @nogc

2020-05-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 May 2020 at 02:50:22 UTC, data pulverizer wrote: Can you also confirm that `@nogc` in a class do the same thing in that class as it does for a function? I don't think it does anything in either case, but if it does anything it will just apply @nogc to each member function in

Re: Is it possible to write some class members in another module ?

2020-05-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 22:01:03 UTC, Vinod K Chandran wrote: Is it possible to write some class members in another module ? You can make some of members be other structs that you aggregate together.

Re: Is it possible to implement operators as ordinary functions?

2020-05-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 02:36:24 UTC, data pulverizer wrote: I was wandering if it possible to implement operators as ordinary functions instead of as member functions of a class or struct for example something like this: nope, it must be done as member functions.

Re: After compiling Hello World with DMD Compiler, .EXE file takes 1-3 seconds to run for the first time

2020-05-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 18 May 2020 at 16:01:14 UTC, kinke wrote: Is that really the case for all D programs on Windows, or just those built with -m32 and thus using the exotic DigitalMars C runtime? -m32mscoff does it too, and -m64 has a slight delay as well (though possible that's just a cold disk

Re: None of the overloads of kill are callable using argument types:

2020-05-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 18 May 2020 at 20:11:25 UTC, BoQsc wrote: I'm trying to kill my own process Don't kill yourself, just `return` from main.

Re: Spawn a Command Line application Window and output log information

2020-05-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 18 May 2020 at 16:36:11 UTC, BoQsc wrote: Would this require GUI library and how can this be achieved? you might enjoy using my terminal lib https://code.dlang.org/packages/arsd-official%3Aterminal include that and set "subConfigurations": { "arsd-official:terminal":

Re: After compiling Hello World with DMD Compiler, .EXE file takes 1-3 seconds to run for the first time

2020-05-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 18 May 2020 at 15:47:40 UTC, BoQsc wrote: It seems strange that on the first run after D language compilation. Hello World program takes 1-3 seconds to launch. That's the Windows virus scanner again. It sees D programs as unusual and gives them additional scrutiny... You can set

Re: Testing template parameter has given API

2020-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
try changing delegate to function, on the type itself it is often function

Re: How to run program with "dmd -i" compiler swich ?

2020-05-15 Thread Adam D. Ruppe via Digitalmars-d-learn
use the -run switch to dmd. Make sure it and te d file name are the LAST arguments. dmd -i other_dmd_args_you_need -run yourfile.d

Re: declaration of inner function is already defined

2020-05-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 13 May 2020 at 12:45:06 UTC, Andrey wrote: Why this works: It's just defined that way. Local functions follow local variable rules - must be declared before use and names not allowed to overload each other. There might be a deeper reason too but like that's the main thing,

Re: Optional type parameter on a template

2020-05-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 May 2020 at 20:36:22 UTC, Luis wrote: I'm trying to make a SparseSet that on function of a optional type parameter, could alongside the index set, store other data. So I need a way to declare a optional type template parameter. A default argument of void is a common way to do

Re: Get unknown symbol (struct, method, class) tagged with User Defined Attributes

2020-05-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 May 2020 at 02:51:39 UTC, Doug wrote: So far I've only seen a way to get unknown UDAs from known symbols but not how to get unknown symbols from UDAs. Is there any documentation for how to get a list of symbols annotated with a specific UDA? see std.traits.getSymbolsByUDA

Re: Probably a trivial question regarding version identifier and unittest

2020-05-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 May 2020 at 01:54:49 UTC, WhatMeWorry wrote: version(demos) unittest { import arsd.terminal; void main() Shouldn't the version identifier demos and the unittest option activate the test block and therefore defines main() which then give the "Start Address"? The

Re: Bug?

2020-05-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 11 May 2020 at 13:06:59 UTC, Steven Schveighoffer wrote: Clearly something isn't connecting properly, it's almost like it's resolving to the function itself instead of calling it. Since the imported front is also a local symbol the compiler probably thinks it is overloaded and not

Re: Bug?

2020-05-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 11 May 2020 at 12:20:06 UTC, Jack Applegame wrote: If you move the import to the global scope UFCS is only defined to work with global scope functions. A restricted import (module : symbol, symbols) puts things in local scope so ufcs doesn't apply. (interestingly an unrestricted

Re: How to get the UDAs for a function parameter correctly?

2020-05-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 11 May 2020 at 02:25:39 UTC, Heromyth wrote: I want to get the UDAs for for a function parameter. Here the test code and I got some errors: I think my blog aside is one of the few if only write-ups on how to do this:

Re: Arsd dom.d examples

2020-05-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 9 May 2020 at 16:10:37 UTC, ByR wrote: Are there are tutorials or examples on how to manipulate HTML using dom.d? Replace tag, text, end so on. ByR I don't think so really. There's a wee bit of documentation here http://dpldocs.info/experimental-docs/arsd.dom.html but for the

Re: Thread to watch keyboard during main's infinite loop

2020-05-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 7 May 2020 at 01:33:12 UTC, Daren Scot Wilson wrote: import core.thread: sleep; It sould be import core.thread : Thread; Thread.sleep(1.secs); // or whatever sleep is a static method on the Thread class.

Re: Get months / years between two dates.

2020-05-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 May 2020 at 19:51:01 UTC, bauss wrote: How will I get the months or years between the two dates? What's the length of a month or a year? That's the tricky part - they have variable lengths. So a difference of one month is not super precise. You could probably just do days /

Re: Retrieve the return type of the current function

2020-05-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 5 May 2020 at 16:36:48 UTC, learner wrote: I mean, without using the function name in the body, like ReturnType!foo ? even easier: typeof(return)

Re: How can I check if an element is iterable?

2020-05-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 3 May 2020 at 20:21:24 UTC, Marcone wrote: How can I check if a variable is iterable? Every variable has a type. You can get it with typeof(varaiable)

Re: How can I check if an element is iterable?

2020-05-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 3 May 2020 at 20:02:09 UTC, Marcone wrote: How can I check if an element is iterable in Dlang? http://dpldocs.info/experimental-docs/std.traits.isIterable.html

Re: Variable assignment in “if” condition in Dlang

2020-05-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 3 May 2020 at 14:53:21 UTC, Baby Beaker wrote: How can I assign a variable in “if” condition in Dlang? depends on exactly what there's also if ( (a = 10) ) with extra parens for special purposes

Re: Hided Subprocess in Dlang

2020-05-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 2 May 2020 at 15:37:09 UTC, Baby Beaker wrote: Error: none of the overloads of `spawnProcess` are callable using argument types `(string, File, File, File, Config)`, candidates are: The example is prolly out of date try spawnProcess(program, null, Config.suppressConsole)

Re: Hided Subprocess in Dlang

2020-05-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 2 May 2020 at 14:06:55 UTC, Baby Beaker wrote: open the command prompt console running this other process. when calling the functions pass Config.suppressConsole to it. like in the doc example here http://dpldocs.info/experimental-docs/std.process.Config.html#suppressConsole

Re: Aliasing current function template instance

2020-05-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 1 May 2020 at 20:28:58 UTC, Jean-Louis Leroy wrote: Something I have overlooked? Any ideas? There's an old rule, that I can't find in the spec anymore but I'm still pretty sure it is there, where taking the address of a template inside a template yields the current instantiation.

Re: in vs inout

2020-04-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 30 April 2020 at 14:00:40 UTC, Arredondo wrote: I had been using inout for some time now for "purely input function parameters". `inout` is more specifically for things you take in, look at, then pass back out. So it forms part of your return value. `const` is for when you are

Re: Building Win32 application via dub

2020-04-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 28 April 2020 at 19:25:06 UTC, Sam E. wrote: I'm a bit surprised to see a linking error given that building directly from `dmd` seems to work fine without any flag. dmd directly uses -m32 whereas dub by default uses -m32mscoff to dmd. The mscoff linker (also used for -m64 btw)

Re: Help, what is the code mean?

2020-04-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 27 April 2020 at 15:24:09 UTC, lilijreey wrote: Thanks your help. where is unsafe in above code? It depends on the context but I assume it is because it is storing a reference to the function across thread boundaries, something normally banned, but since it is (I believe) a

Re: Help, what is the code mean?

2020-04-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 27 April 2020 at 13:29:08 UTC, lilijreey wrote: Hi: In dlang core.thread.osthread has below code, the 654 line code i can understand why write () first, and {m_fn = fn;}() do what? The stdlib uses that pattern from time to time to indicate an unsafe block in an otherwise safe

Re: It won't run in gdb...

2020-04-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Mon, Apr 27, 2020 at 10:56:09AM +, mark via Digitalmars-d-learn wrote: > Thread 1 "DebFind" received signal SIGUSR1, User defined signal 1. The GC sends that signal to pause other threads when it is about to collect. You can tell gdb to just ignore it. handle SIGUSR1 noprint handle

Re: GUI library for DMD 2.090 or DMD 2.091

2020-04-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 24 April 2020 at 15:50:15 UTC, Phrozen wrote: @Adam D. Ruppe, your idea is great, especially for small and unpretentious applications! Very good work, man! if you do decide to use my thingy let me know how it goes for you. I often don't recommend it in threads cuz it kinda sucks,

Re: GUI library for DMD 2.090 or DMD 2.091

2020-04-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 24 April 2020 at 13:45:22 UTC, Phrozen wrote: I need something simple - a modal window with 3 buttons and a two text boxes This sounds easy with my minigui.d. My library doesn't have a lot of features, no fancy graphics, and layout can be a bit clunky... but check out this code:

Re: How make DMD auto link imported modules?

2020-04-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 April 2020 at 21:36:57 UTC, Marcone wrote: When I create a module, for exemple mymodule.d and import im my main program using "import mymodule" I need add mymodule.d in DMD command line manually. How can make it automatic? dmd -i

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 18:05:39 UTC, Jean-Louis Leroy wrote: Interesting example, but all hope is not lost. `a` could (should?) be passed as an alias in __parameters. Well, __parameters itself actually kinda works. The compiler knows it is an expression and can stringify it or evaluate

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 17:31:32 UTC, Jean-Louis Leroy wrote: Well, can't do. I need this purely at compile time, and cross-module. And the CTFE engine gets weird with it too dmd will have to fix this. But default parameters might not be possible in general at CT anyway... it is

Re: Extracting user defined attributes on function parameters

2020-04-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 17 April 2020 at 16:40:15 UTC, Jean-Louis Leroy wrote: Alas the presence of parameter UDAs breaks std.traits.ParameterDefaults: import std.traits; struct attr; void f(@attr int); This part seems fine... pragma(msg, ParameterDefaults!f.stringof); It is this, specifically,

Re: make dub use my version of dmd

2020-04-16 Thread Adam D. Ruppe via Digitalmars-d-learn
For future reference, newer dubs (v 1.17 + i think) allow --compiler=dmd-version for example. You need to put the exe in your PATH and rename it yourself, but it recognizes *dmd-* (or *ldc2-* or *gdc-*) all the same so you can specifiy them. I was doing that in early versions of my android

Re: Extracting user defined attributes on function parameters

2020-04-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 April 2020 at 21:54:14 UTC, Jean-Louis Leroy wrote: O.kay. It looks like `is` is D's Swiss army chainsaw. Aye, is and __traits are the two built-in compile-time reflection avenues. The phobos std.traits things (for the most part, look at the source for the default

Re: Extracting user defined attributes on function parameters

2020-04-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 14 April 2020 at 21:35:12 UTC, Jean-Louis Leroy wrote: I can see them: There's some weird tricks to it. Check out my old blog sidebar about it here: http://dpldocs.info/this-week-in-d/Blog.Posted_2019_02_11.html#how-to-get-uda-on-a-function-param

Re: How to detect whethere if a JSON node exists

2020-04-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 13 April 2020 at 02:20:39 UTC, Adnan wrote: Now in the above inner loop getStr(node["com"].str()) crashes in runtime if an array does not contain "com" node. I want to avoid that. How should I proceed? Try: if("com" in node) { }

Re: Is it possible to store different subclasses in one array?

2020-04-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 13 April 2020 at 01:42:51 UTC, Leonardo wrote: Is it possible to store different subclasses in one array? In C#, we have this example, but how I do that in D? Did you try BaseItem[] GameItems; GameItems ~= new Weapon(); yet?

Re: docs.json is incomplete

2020-04-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 11 April 2020 at 15:14:21 UTC, Adam D. Ruppe wrote: I'll come back to it later tonight or something, but yeah definitely bugs on my end there, so I'll take care of it. Just rebuilt your page with the new stuff... * fixed a bunch of bugs in private: detection. Most your modules

Re: docs.json is incomplete

2020-04-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 11 April 2020 at 14:49:17 UTC, Anonymouse wrote: Yes, http://kameloso.dpldocs.info/kameloso.plugins.seen.html. onBusMessage is private like the other functions, but it shows up. (Additionally the public imports are private.) Oh, I see, my colon attribute code is bad, it doesn't

Re: docs.json is incomplete

2020-04-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 11 April 2020 at 06:49:21 UTC, Anonymouse wrote: I'm trying to get docs for my project hosted, and everything works, except there are entries missing. Looking at the generated docs.json there's simply a lot of omitted stuff. My dpldocs.info site doesn't use docs.json, it goes

Re: To get memory from another process.

2020-04-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 9 April 2020 at 17:23:19 UTC, Quantium wrote: We can use WinAPI. Are there any D libs to use WinAPI? import core.sys.windows.windows; it is all built in.

Re: D on android and d_android

2020-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 7 April 2020 at 14:51:15 UTC, H. S. Teoh wrote: 1) Follow LDC wiki to build an Android cross-compiler and cross-compiled LDC libraries (this may already be prepackaged with the latest LDC releases). They are - this is all automatic just-works now (if you download the

Re: D on android and d_android

2020-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 6 April 2020 at 08:38:03 UTC, Jan Hönig wrote: Is there some "Hello World!" example for D on Android? So I did a tiny thing in the repo: https://github.com/adamdruppe/d_android/tree/master/android-dub-test if you open that in android studio it should load up, and the makefile is

Re: D on android and d_android

2020-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 7 April 2020 at 11:45:24 UTC, burt wrote: I managed to get it to compile. I had to add __bss_end__ symbol myself and set the value to the value of the `_end` symbol or it wouldn't work. A PR to the LDC druntime is wat caused the __bss_end__ symbol to be missing [0]. Blargh it was

Re: D on android and d_android

2020-04-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 2 April 2020 at 11:29:24 UTC, burt wrote: Anyway, I don't think this fails to work because of an error in the d_android library. If you find anything else that may cause it, I am glad to know, but thank you for your help. Well, it is supposed to be a "just works" setup helper, so

Re: D on android and d_android

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 15:04:02 UTC, burt wrote: Well I'm European, so with 10.010 kB I mean 10010 kB = 10.010 MB in American/British. ah, of course. Well, I won't be able to finish it today anyway, so take your time. I rewrote the downloader so it goes straight from ldc releases

Re: determine ldc version in static if or version?

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 2 April 2020 at 01:27:26 UTC, Nicholas Wilson wrote: https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/intrinsics.di#L22-L34 ah excellent that will do. thanks!

determine ldc version in static if or version?

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
I want to do like static if(__LDC_VERSION == 1.19) { // declaration } All the tricks I know that I have tried so far give the dmd numbers. Perhaps I could use that to identify a particular version as a hack, but I specifically am curious about the ldc version because of a change they made

Re: What does the [] operator do here?

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 19:35:30 UTC, Net wrote: from the below code, the expression "case [c]": That's just an array literal, so the same as like "" ~ c

Re: Array fill performance differences between for, foreach, slice

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 15:04:44 UTC, Jesse Phillips wrote: It is nice that bounds checks remain in place when using release and the code is @safe. Yeah, it used to be even worse than it is now, but it is still a terrible switch that should NEVER be used. There are always better ways

Re: D on android and d_android

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 14:54:35 UTC, burt wrote: libphobos2-ldc.a and libphobos2-ldc-debug.a. Sizes are 2511 kB, 4792 kB, 10.010 kB and 17.378 kB respectively. Those latter two should be megabytes not kilobytes the download must have failed. can i come back to it in a few hours?

Re: D on android and d_android

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 14:20:25 UTC, burt wrote: Some examples of errors are: Those mean it isn't linking in the libs at all... ugh. do ldc2 -v and it will tell you where the config file is. open that up and see if it has teh correct paths under a section that looks kinda like

Re: D on android and d_android

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 14:13:32 UTC, burt wrote: I also wonder if there's a difference between the libphobos2-ldc and libphobos2-ldc-debug.a libraries? Do those mangle differently and could that cause the linker errors? maybe. what are the errors?

Re: D on android and d_android

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 13:36:29 UTC, burt wrote: Sorry, I must have misread this. My LDC version was 1.20.1, not 1.19. did that fix the linker error? The runtimes it downloads are specifically built against 1.19. But libs for the other versions are available too, you just need to

Re: Array fill performance differences between for, foreach, slice

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 06:48:09 UTC, Jacob Carlborg wrote: You have not enabled optimizations. You should compile with `-O -release -inline` to enable all optimizations. -release should *never* be used. You're trading memory safety and security holes for a few microseconds of execution

Re: D on android and d_android

2020-04-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 08:50:01 UTC, burt wrote: I found a README [0] that mentions an "android-dub-build.d" script, which should be a wrapper around `dub build` Ah, I forgot to update that file. There is no android-dub-build anymore, instead the android-setup changes the main

Re: Where is the latest android dev info?

2020-03-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 26 March 2020 at 10:07:35 UTC, BetaDamnit wrote: Maybe you have some free time with nCoV? nope, it is even worse for my time right now. It seems rather straight forward, just use ldc2, ndk linker, and proper linking to android libs to use the functionality Yeah, that's

Re: Where is the latest android dev info?

2020-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
My thingy can help https://github.com/adamdruppe/d_android a lot is built into ldc now too which is really nice as well. i need to update my repo to use the new ldc features, hoping to tomorrow. i'm just behind on a lot of things lol

Re: Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 23 March 2020 at 14:26:46 UTC, Anders S wrote: do you mean I should loop through each pos till strlen(cellTab[CellIndex].name) to find "\0"? strlen is ok, that gives the answer itself. Just slice to that. cellTab[CellIndex].name[0 .. strlen(cellTab[CellIndex].name.ptr)] could do

Re: Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
My first thought is to!string(cellTab[CellIndex].name) is wrong, if it is a char[20] you should be scanning it to find the length and slicing. Maybe [0 .. name.indexOf("\0")] or whatever. You also shouldn't be building a query by concatenation.

Re: Wired question related with Chinese characters

2020-03-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 23 March 2020 at 01:18:15 UTC, walker wrote: Which function should I use when I read Chinese characters in the terminal? Terminal.getline *might* work in my lib, but if there's combining codepoints I'm not sure. You can try it though and let me know if you are already using the

Re: Wired question related with Chinese characters

2020-03-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 22 March 2020 at 15:19:13 UTC, walker wrote: writeln(var1); writeln calls the wrong function for the Windows console. You can kinda hack it by changing the code page like Steven said (which has other bugs though, but works for many cases), or you can call the correct function -

Re: need help to get member function const address

2020-03-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 March 2020 at 04:30:32 UTC, Calvin P wrote: my question is, how to get it in compile time like static function address: = struct A { void d(){}; static void fn(){}; } enum FN = // static method address is ok enum A1 = (&__traits(getMember, A,"d")).funcptr;

Re: How catch any error in Dlang like Python try-except?

2020-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 15 March 2020 at 02:11:21 UTC, Marcone wrote: It is very useful when making tests. But only who came from interpreted languages can understand. The compiler catches all compile errors. It is impossible to even run a program if there is even a single compile error. Thus they cannot

Re: Why can't the compiler properly detect the type of Array!string("something")?

2020-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 14 March 2020 at 23:39:11 UTC, Adnan wrote: Full code this worked for me when i copy/pasted it... are you sure that has the error? if so what compiler version you on?

Re: @property with opCall

2020-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 March 2020 at 10:09:56 UTC, Calvin P wrote: @property exists so many years, Druntime & Phobos use it 2280 times. I can't believe it is not recommended. They never implemented it right. This opCall type thing was THE case we brought up to introduce @property in the first

Re: static foreach / How to construct concatenated string?

2020-03-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 7 March 2020 at 16:30:59 UTC, Robert M. Münch wrote: Which of course doesn't work... I didn't find any reference how to build-up strings in a statif foreach loop. Is this possible at all? Use regular foreach with a regular string. Put that inside a function. Then simply use

Re: How to dispatch a class function for an object accessed by handle?

2020-03-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 March 2020 at 15:05:56 UTC, wjoe wrote: But didn't like the string part and that's when I introduced the alias fn because I figured maybe it's possible to do something like: factory.dispatch!(Bitmap.load)(handle, path); and get the Bitmap part from that alias and hence save the

Re: How to dispatch a class function for an object accessed by handle?

2020-03-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 March 2020 at 14:05:55 UTC, Steven Schveighoffer wrote: Adam's way doesn't work either, because the call doesn't use the alias, but just instantiates opDispatch with the new name!' oh yikes, how did I not notice that?! so yeah just kinda screwed. I'd probably suggest at tis point

Re: How to dispatch a class function for an object accessed by handle?

2020-03-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 March 2020 at 11:51:54 UTC, wjoe wrote: I don't understand this error message. Which type can't be resolved? I don't know. It works if you rename the inner one but it doesn't like eponymous templates like this. I suspect either the spec subtly doesn't allow it or a compiler

Re: Safe cast

2020-03-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 March 2020 at 13:03:22 UTC, drug wrote: Here x will be null. You can use `enforce(x !is null);` if you want exception. or since enforce returns it thing, just do B b = enforce(cast(B) x); you can also check easily in if statements: if(auto b = cast(B) x) { // x was a b, use

Re: akePureMalloc cannot be interpreted at compile time

2020-03-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 5 March 2020 at 20:13:11 UTC, Adnan wrote: auto d = some!(some!int(9)); My guess would be this line is causing your trouble. That is trying to pass an instance as a value at compile time, thus triggering ctfe. Since you use the `Array` object inside and that uses

Re: How to dispatch a class function for an object accessed by handle?

2020-03-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 5 March 2020 at 14:24:33 UTC, wjoe wrote: Implement this for free functions i would do something like this void dispatch(alias fn, ARGS...)(Handle handle, ARGS args) Why do you need an `alias fn` like that? My suggestion would be to just use the `opDispatch` magic method that

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