Re: Beta 2.108.0

2024-03-20 Thread WebFreak001 via Digitalmars-d-announce

On Saturday, 2 March 2024 at 17:40:29 UTC, Iain Buclaw wrote:
Glad to announce the first beta for the 2.108.0 release, ♥ to 
the 35 contributors.


This release comes with 7 major changes and 48 fixed Bugzilla 
issues, including:


 - In the language, support has been added for Interpolated 
Expression Sequences.

 - In phobos, std.uni has been upgraded to Unicode 15.1.0.
 - In dub, the fetch command now supports multiple arguments, 
recursive fetch, and is project-aware.


http://dlang.org/download.html#dmd_beta
http://dlang.org/changelog/2.108.0.html

As usual please report any bugs at
https://issues.dlang.org

-Iain
on behalf of the Dlang Core Team


woah this release is amazing! It's solving some of my long 
standing pain points missing with the language (in particular 
named arguments as struct initializer replacements and 
interpolated strings) - the other features may only be very niche 
things, however they are absolutely plenty appreciated since they 
drastically make things easier (hexstrings) or even possible in 
the first place (magic initializer thingies) for library code and 
generated code.


This gives me excitement like older D releases used to feel 
again, as well as in the forums real usage of D in projects or 
samples instead of pointless discussions seem to also be gaining 
more popularity again.


Can't wait for the full release, gonna try out using new features 
from this beta one already.


Re: New DUB documentation

2023-11-28 Thread WebFreak001 via Digitalmars-d-announce

On Monday, 27 November 2023 at 13:25:20 UTC, Bastiaan Veelo wrote:

On Friday, 24 November 2023 at 11:11:53 UTC, BoQsc wrote:
Darker blending indistinct colors (dark red, dark background), 
way smaller fonts.


I see your screenshots, but that is not what it looks like for 
me in Chrome on Windows. I am seeing black text on white 
background with red links. Pretty much like the rest of the D 
web ux. Is there a dark theme you have enabled?


The font does look slightly smaller, though.

-- Bastiaan.


the button next to the search bar toggles between light and dark 
theme:


![theme switcher button screenshot](https://wfr.moe/f6McOo.png)


Re: New DUB documentation

2023-11-28 Thread WebFreak001 via Digitalmars-d-announce

On Friday, 24 November 2023 at 11:32:18 UTC, BoQsc wrote:
Also it's a good idea to maintain the same style as dlang forum 
and dlang website, along with dlang tour and online dlang 
editor. The dlang webdesign choice feels really solid and 
robust. At least from my perspective.


If someone needed a dark theme dub documentation. A simple 
button to toggle it would have been enough.


Small tweaks for layout and small tweaks overall for more 
professional look and efficiency of use. Would have been enough.


I don't know what you are talking about? The dark theme is just a 
single button press and the default is light theme which is very 
similar to the dlang page (unless you have changed your system 
theme to dark theme, it uses the browsers preference, if any)


The dub docs are hosted on https://github.com/dlang/dub-docs, you 
can PR CSS changes there if you want to change the link color in 
dark theme. (I don't really use dark theme so I never looked at 
it too much, it came in as a contribution)


Re: New DUB documentation

2023-11-22 Thread WebFreak001 via Digitalmars-d-announce

On Wednesday, 22 November 2023 at 21:52:12 UTC, claptrap wrote:
On Wednesday, 22 November 2023 at 21:35:34 UTC, WebFreak001 
wrote:

[...]


IMO you have to many menus, you have menu bar across the top, 
left side menu, right side menu. So it's like you need to grep 
all three of them and how the are related to work out where you 
are.


A single table of contents type menu would be better IMO, a 
left sidebar that gives links to all the pages. It would make 
it a lot easier to understand where you are in the overall 
structure of the guide.


the layout is standard from material for mkdocs and widely used 
in other projects, no plans on changing that for now, the 
experience is more efficient for when you get used to it too.


New DUB documentation

2023-11-22 Thread WebFreak001 via Digitalmars-d-announce
the revamped DUB documentation I started a while ago is now 
deployed on https://dub.pm


A bunch of pages are still WIP, but the already done pages have a 
bunch of new information and should be better structured. I 
recommend giving the new documentation a try, maybe you will 
learn something new about DUB.


If you find anything to edit, the "Edit this Page" button makes 
it trivially easy - it's all standard markdown files now that are 
easily editable.


If you previously often looked at the recipe page that contained 
all the information in a single page, you will find most of the 
information on https://dub.pm/dub-reference/build_settings/ now 
and there are even more details on separate pages now.


The site's built-in search on the page works great and runs fully 
offline, try it out! It will find your search across the entire 
documentation. CLI documentation is now also included more 
similar to the man page format here.


BeerConf Japan

2023-10-05 Thread WebFreak001 via Digitalmars-d-announce
hi, if you are in Tokyo right now, we are doing a small meetup 
this Sunday (2023-10-08)


We are still planning the exact details where and when to go in 
the dlang-jp slack, probably evening at some cafe somewhere 
around Shibuya. I will post updates on exact locations here.


Re: All-new improved, better readable, maintainable DUB documentation

2023-09-01 Thread WebFreak001 via Digitalmars-d-announce

On Friday, 1 September 2023 at 11:52:18 UTC, WebFreak001 wrote:
bump (for email readers, URL of this thread: 
https://forum.dlang.org/post/ojoiwbcftqsxbsviv...@forum.dlang.org)


- added some new pages with new content
- github issues still contain information for contributors that 
want to help improving the documentation
- on https://docs.webfreak.org it now shows links to the issues 
with content hints and suggestions on each page, so that you 
can easily find pages to work on


now PR to make it official for dub.pm: 
https://github.com/dlang/dub-docs/pull/54


All-new improved, better readable, maintainable DUB documentation

2023-09-01 Thread WebFreak001 via Digitalmars-d-announce
bump (for email readers, URL of this thread: 
https://forum.dlang.org/post/ojoiwbcftqsxbsviv...@forum.dlang.org)


- added some new pages with new content
- github issues still contain information for contributors that 
want to help improving the documentation
- on https://docs.webfreak.org it now shows links to the issues 
with content hints and suggestions on each page, so that you can 
easily find pages to work on


DUB 1.33 package migration script

2023-08-18 Thread WebFreak001 via Digitalmars-d-announce
hi, if you are having issues with mixed old/new dub installations 
on your system, which use different package versions and to avoid 
potentially double-downloading all your packages, you can run 
this script to automatically move all the old paths to the new 
paths, while adding symlinks (or copying on windows) to the old 
location again, to keep compatibility with older dub versions:


https://github.com/WebFreak001/dub-migrate

This includes using newer serve-d versions with older dub 
versions installed, making serve-d able to actually find the 
packages for auto-completion again.


It's safe to run the migrate script any number of times, it will 
only upgrade what doesn't exist yet.


Re: DScanner v0.16.0-beta.1 - looking for IDE dev feedback

2023-07-09 Thread WebFreak001 via Digitalmars-d-announce

On Sunday, 9 July 2023 at 07:54:38 UTC, Christian Köstlin wrote:

On 08.07.23 23:59, WebFreak001 wrote:

[...]

Sounds to good to be true, will give it a try for sure!!!

Thanks a lot.

Kind regards,
Christian


thanks, feel free to leave feedback about the CLI and fixes for 
existing or new diagnostics you would like to see.


I just fixed a bug in the CLI that you reported and with the 
latest version it should work again (CI tested now): 
https://github.com/dlang-community/D-Scanner/releases/tag/v0.16.0-beta.3


Re: DScanner v0.16.0-beta.1 - looking for IDE dev feedback

2023-07-09 Thread WebFreak001 via Digitalmars-d-announce

On Saturday, 8 July 2023 at 21:59:53 UTC, WebFreak001 wrote:

[...]


https://github.com/dlang-community/D-Scanner/releases/tag/v0.16.0-beta.2

updated API in v0.16.0-beta.2: `--report` includes all auto-fixes 
that don't need any resolving now, as well as the names for the 
to-be-resolved auto-fixes. This way you can show the user that 
actions are available before trying to query them. (although in 
the future new classes of auto-fixes could be introduced that are 
not tied to diagnostics. The API isn't built for this right now 
though and isn't expected in the near future)


DScanner v0.16.0-beta.1 - looking for IDE dev feedback

2023-07-08 Thread WebFreak001 via Digitalmars-d-announce

https://github.com/dlang-community/D-Scanner/releases/tag/v0.16.0-beta.1

## For IDE devs:

the new D-Scanner version comes with a major new improvement: 
automatic fix suggestions for diagnostics. As IDE dev you can use 
the existing `--report` functionality to get JSON parsable output 
for the issues, along with new information such as start/end byte 
indices.


Then when the user wants to query auto-fixes for any given issue 
(or just in general at any location in the file), use `dscanner 
--resolveMessage b512 file.d` to list the resolved auto-fixes at 
the given location. See the README.md for more information.


Looking for feedback on the API and if you need any changes. 
Additionally this API is usable with D-Scanner as a library as 
well.


## For users:

`dscanner fix source/` can be used to interactively auto-fix all 
issues inside the source/ directory that have available autmoatic 
fixes.


D-Scanner 0.15.0

2023-07-05 Thread WebFreak001 via Digitalmars-d-announce

Hello everyone,

today there is a new D-Scanner release, key features include:

- proper diagnostic ranges (underlining code / end locations for 
issues)
- also includes file byte index instead of only line:column in 
the JSON formats (for IDE integration)

- pretty printing format, with colored output
- new easier way to call D-Scanner for humans: `dscanner lint 
source/`


https://github.com/dlang-community/D-Scanner/releases/tag/v0.15.0

![example colored 
output](https://github.com/dlang-community/D-Scanner/assets/2035977/644d1cea-276f-4a9c-af8c-f445aad95806)


Looking forward to feedback for the output style and warnings.

Adding your own diagnostics to D-Scanner is quite easy, give it a 
try if you have ideas! You have full access to the AST of the 
input file, as well as a very basic symbol index to attempt to 
lookup symbols in the entire project (although it's not always 
accurate yet, especially since D-Scanner usually isn't configured 
to use the correct import paths)


Re: Best way to convert between GBK/GB18030 to utf8 ?

2023-05-23 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 23 May 2023 at 02:58:21 UTC, John Xu wrote:

What is the best way to convert a GBK/GB18030 file contents,
i.e. read via: std.stdio.read(gbkFile).to!string ,
to utf8 encoding ?


I don't think we have any implementation of that encoding yet. If 
you decide to make your own, don't forget to share it with the 
forum.





Re: Autoformatter for SDLang

2023-05-09 Thread WebFreak001 via Digitalmars-d-learn

On Saturday, 29 April 2023 at 11:45:24 UTC, Per Nordlöw wrote:
Does anybody know of an autoformatted of SDLang, specifically 
for dub.sdl?


just made a small tool for it: https://github.com/Pure-D/sdlfmt


Re: Tutorial on LDC's -ftime-trace

2023-05-01 Thread WebFreak001 via Digitalmars-d-announce

On Monday, 1 May 2023 at 14:00:23 UTC, Mike Parker wrote:
Dennis Korpel has a new tutorial out on the foundation's 
YouTube channel, showing how to employ LDC's -ftime-trace 
option to improve your project's compile times. This can come 
in handy if you're heavily using metaprogramming or CTFE.


https://youtu.be/b8wZqU5t9vs


cool, thanks for the tutorial! These tutorials can help show 
things that are used commonly, that can ideally be simplified in 
IDEs such as code-d/serve-d as well.


The tracy viewer or web viewer could for example be embedded in 
the IDE.


Compilation times for modules and methods could also be shown 
inside the editor / code. There was once an experimental setting 
in code-d with dmd for imports which just tried compiling with a 
single import, but this would be much more accurate and be able 
to display times relative to the total compilation time.




Re: DIP1044---"Enum Type Inference"---Formal Assessment

2023-04-25 Thread WebFreak001 via Digitalmars-d-announce

On Tuesday, 25 April 2023 at 04:54:43 UTC, Mike Parker wrote:
I submitted DIP1044, "Enum Type Inference", to Walter and Atila 
on April 1. I received the final decision from them on April 
18. They have decided not to accept this proposal.


https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1044.md

The said the proposal was well done and an interesting read, 
but found it to be too complex for insufficient benefit. They 
provided the following list of concerns that led them to their 
decision:


* Given that D already has `with`, `alias`, and `auto`, it does 
not seem worthwhile to add a special case for enums.
* Semantic analysis in D is strictly bottom-up. This proposal 
would add top-up type inference on top of that. This presents 
problems in handling function and template overloads, as well 
as variadic parameter lists.
* The proposal only allows ETI in some contexts. This is 
potentially confusing for the programmer, particularly in the 
presence of mixin templates (which draw symbols from the 
instantiation context) and function overloads.
* Symbol tables can get very large. Lookups are done via hash 
table for max speed, but this will not work for ETI. There may 
be a very large number of "enums in scope", and each one will 
have to be searched to resolve a member.
* ETI is similar to ADL (Argument Dependent Lookup) in C++. 
Walter implemented ADL in the Digital Mars C++ compiler and is 
strongly against allowing anything like it in D. He finds it 
slow and complex, and few people really know how it's going to 
work.


Regarding enums in switch statements, Walter suggested we could 
shorten the `with final switch` syntax such that the `with` is 
implicitly applied to the type of the switch variable:


```D
auto myEnum = MyEnum.a;
with final switch (myEnum) { }
```

Alternatively, we could make the `with` implicit for case 
statements, but that would break existing code.


I'm a little glad for reading and reviewing code that this didn't 
get through, at least without IDE, but I think this would have 
been quite a useful feature for writing code.


However I think we probably should still implement this in DCD / 
have better auto-suggest according to the rules here. I think it 
will be similarly useful having better auto-complete suggestion 
contexts compared to having new syntax in the language. (maybe 
being able to trigger it explicitly using $ at the start, but 
definitely want to have these suggestions being prioritized)


Re: Mir-ion:YAML Example

2023-04-12 Thread WebFreak001 via Digitalmars-d-learn

On Wednesday, 12 April 2023 at 12:00:14 UTC, Vino wrote:

Hi All,

  Can some point me where i can find examples on how to use 
mir-ion YAML


From,
Vino.B


documentation is very sparse, but essentially with mir-ion you 
import the different ser/deser packages that you would like to 
use. If you for example want to deserialize YAML to a custom 
struct, you use


```d
import mir.deser.yaml;

struct CustomStruct
{
string foo;
uint bar;
}

void main()
{
string yamlString = `{foo: str, bar: 4}`;
CustomStruct s = yamlString.deserializeYaml!CustomStruct;

assert(s == S("str", 4));
}
```

If you want to deserialize arbitrary values and introspect them 
at runtime, you use `YamlAlgebraic` instead of `CustomStruct`, 
which you can think of like std.json : JSONValue, but utilizes 
mir's algebraic structures, which work more like std.sumtype.


To convert algebraic values to custom structs later, you use 
mir.ion.conv : serde, which basically just internally serializes 
the data and deserializes it again (but a little more efficiently)


more deserialization examples in the unittests: 
https://github.com/libmir/mir-ion/blob/62c476a6a00d0d5ddfb3585bdfbe520d825e872b/source/mir/deser/yaml.d


and for serialization you use `serializeYaml` from 
`mir.ser.yaml`, see 
https://github.com/libmir/mir-ion/blob/62c476a6a00d0d5ddfb3585bdfbe520d825e872b/source/mir/ser/yaml.d


Re: Convert binary to UUID from LDAP

2023-03-28 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 28 March 2023 at 05:05:58 UTC, Alexander Zhirov wrote:
On Tuesday, 28 March 2023 at 00:51:43 UTC, Steven Schveighoffer 
wrote:

auto uuid = UUID(*cast(ubyte[16]*)youruuiddata.ptr);


```d
ubyte[] arr = 
cast(ubyte[])value.attributes["objectGUID"][0].dup;

writeln(UUID(cast(ubyte[16])arr.ptr));
```

`Error: cannot cast expression 'cast(ubyte*)arr' of type 
'ubyte*' to 'ubyte[16]'`


No, it's not possible to transform. The array is initially 
`immutable(char[])`.


the formatting messed up here. Try this code:

```d
auto uuid = UUID(
(cast(const(ubyte)[]) value.attributes["objectGUID"][0])
[0 .. 16]
);
```

no need to `.dup` the values - UUID can work without manipulating 
the original data, so we just need to cast the 
`immutable(char)[]` to `const(ubyte)[]`


The LDAP library should probably really instead expose `ubyte[]` 
instead of `string`


Re: How to debug and watch globals in windows debugger?

2023-03-28 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 28 March 2023 at 04:22:24 UTC, Richard (Rikki) Andrew 
Cattermole wrote:

On 28/03/2023 2:25 PM, ryuukk_ wrote:
On Tuesday, 28 March 2023 at 01:06:50 UTC, Richard (Rikki) 
Andrew Cattermole wrote:

Have you tried installing mago?

https://github.com/rainers/mago

There are instructions for vs-code in README.


I did not try mago, but it shouldn't be needed as pdb is 
universally understood by tools


Agreed, I would expect globals (including TLS) to work without 
a debugger extension.


While i will try with mago, it shouldn't satisfy us, 
workarounds are temporary solutions


Its not a workaround, mago (in this case) is an extension to 
MS's debugger framework which provides D specific features, 
you'd want it regardless if you work with the debugger with D a 
lot. Debuggers typically have language specific features to 
make them easier to work with.


Jan should be shipping this I think.


I have looked into trying to get mago to work so far, but didn't 
have any working state yet, which is why that is currently stuck. 
(+ I don't personally use Windows for development, so I don't 
have much usage experience for code-d / debugging integration, 
outside when I actively develop Windows fixes on it)


If you get mago to work with vscode feel free to tell me how you 
did it so we can add a debug configuration preset for code-d 
users / other users who want to manually use it.


Re: How to debug and watch globals in windows debugger?

2023-03-28 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 28 March 2023 at 01:04:19 UTC, ryuukk_ wrote:
I've now waste an entire day trying to figure out what's wrong, 
perhaps trusted D for my projects was a bad idea, i now look 
like a fool


sorry to hear that, I haven't really been looking to much into 
the debugging problems here yet. My extension mostly just 
integrates the existing tools here (Visual Studio Debugger / GDB 
+ whatever is emitted in the pdb files)


What I was talking about is that it's possible dmd didn't emit 
the globals information in any way that the GDB / Visual Studio 
Debugger understand right now. I'm not a debugger expert myself, 
looking into this is probably something that would take a bit of 
research about the DWARF / PDB formats and checking how DMD / LDC 
emit it. I think you can probably get some great help here from 
Martin Kinkelin. (I think the windows and linux debug info 
emission works differently / are different modules, so there 
might be discrepancies here)


I can help you point towards where to check and who to ask here, 
but I don't think I can help you actually solve this issue right 
now. I haven't really been focusing too much on the debugger, 
especially not on the implementation of debug symbol emissions 
and the debugger itself. I have only been adding a few scripts 
here to get the best out the debugger that we currently have. 
More things require more investment into actually improving the 
project.


I'm quite glad about your contributions you have been doing so 
far and I think the issues you are opening are good to find stuff 
to work on. (the DCD PRs you have open right now are very nice 
and appreciated, but need a bit of work still done to them before 
they can be merged. I have reviewed them, but didn't have time to 
actually make the changes and test them yet - if you want to get 
these changes in faster you can also implement or reply to my 
review comments)


Further people you could ask about here:
- Iain Buclaw (GDC developer), can probably tell you about what 
gcc does here and possibly has insights into the D backend code 
that generates debug info

- Martin Kinkelin (LDC developer), ditto
- Luís Ferreira (ljmf00 on discord) - has been working on LLDB 
for SAoC and implementing a bunch of things - if things are 
missing on the debugger side, he can probably help you with LLDB 
implementations (you probably only need to go this far if we want 
to add support for new custom data structure things that D has - 
most things can already be realized with the debug symbols)


Re: godot-dlang v0.2.0

2023-02-25 Thread WebFreak001 via Digitalmars-d-announce

On Saturday, 25 February 2023 at 07:45:24 UTC, evilrat wrote:

# Release godot-dlang v0.2

[...]


Awesome! Thanks for the great work on this. Godot is one of my 
favorite game engines to work with (for small Game Jams at least)


Seeing updates to Godot 4 is great to see ahead of the stable 
release! I also see there is still a bunch to work on, recently I 
haven't had much time for this, but I will see if I can help out 
somewhere ^^


importC - how to use more effectively?

2023-02-22 Thread WebFreak001 via Digitalmars-d-learn
I just first time used importC in a prototype project I just 
worked on. I used it to just import `libevdev.h` on linux to 
register a custom input device / make a simple userspace input 
driver.


Now libevdev comes with two header files: libevdev.h and 
libevdev-uinput.h


Q1) Since libevdev-uinput.h included libevdev.h, I could simply 
import that to get everything. What would I do in more complex 
libraries that are composed of multiple header files though?


I had a small problem: linux/input.h was included, but not found 
/ not properly processed, so I had to manually look that up in 
the correct architecture folder of my linux distro.


What I now did was copy-pasting the files both from libevdev and 
from linux/input.h from my local system into my project 
directory, running `gcc -E` and manually cleaning up things, so 
that stuff like `u8` existed. (using a package in D that I would 
`__import` to include compat things)


Q2) How would I do this without manually copying and editing the 
header files, so that it would work on other people's machines as 
well, using their local headers?


---

I'm quite a fan of how easy it was using importC to get libevdev 
running in my custom program and quickly making a basic custom 
input device, exactly with the same syntax and functions as in C, 
but this only really seems to work inside the prototyping phase. 
What would be the next steps if I wanted to make e.g. a libevdev 
wrapper to put on DUB?


Q3) Would generating D code from importC be possible for this?


Re: WildCAD - a simple 2D drawing application

2023-01-31 Thread WebFreak001 via Digitalmars-d-announce

On Tuesday, 31 January 2023 at 15:03:50 UTC, bachmeier wrote:
On Monday, 30 January 2023 at 20:51:59 UTC, Richard (Rikki) 
Andrew Cattermole wrote:



It isn't. WebFreak has an on-going project to replace it.

https://forum.dlang.org/post/ojoiwbcftqsxbsviv...@forum.dlang.org

https://docs.webfreak.org/


That's quite an improvement. Perhaps it should be announced 
again, because I don't remember seeing the original post.


I already posted it twice on two separate dates and tried to bump 
them after some time too, I think there is just not much demand 
in improved DUB docs, people probably think it's kinda fine 
already.


However for newcomers I think it's very worthwhile to do more 
stuff on there.


Re: Getting the default value of a class member field

2022-12-02 Thread WebFreak001 via Digitalmars-d-learn

On Friday, 2 December 2022 at 04:14:37 UTC, kinke wrote:

On Friday, 2 December 2022 at 00:24:44 UTC, WebFreak001 wrote:
I want to use the static initializers (when used with an UDA) 
as default values inside my SQL database.


See 
https://github.com/rorm-orm/dorm/blob/a86c7856e71bbc18cd50a7a6f701c325a4746518/source/dorm/declarative/conversion.d#L959


With my current design it's not really possible to move it out 
of compile time to runtime because the type description I 
create there gets serialized and output for use in another 
program (the migrator). Right now it's simply taking the 
compile time struct I generate and just dumping it without 
modification into a JSON serializer.


[...]


Okay, so what's blocking CTFE construction of these models? 
AFAICT, you have a templated base constructor in `Model`, which 
runs an optional `@constructValue!(() => Clock.currTime + 
4.hours)` lambda UDA for all fields of the derived type. Can't 
you replace all of that with a default ctor in the derived type?


```
class MyModel : Model {
int x = 123;// statically initialized
SysTime validUntil; // dynamically initialized in ctor

this() {
validUntil = Clock.currTime + 4.hours;
}
}
```

Such an instance should be CTFE-constructible, and the valid 
instance would feature the expected value for the `validUntil` 
field. If you need to know about such dynamically generated 
fields (as e.g. here in this time-critical example), an option 
would be a `@dynamicallyInitialized` UDA. Then if you 
additionally need to be able to re-run these current 
`@constructValue` lambdas for an already constructed instance, 
you could probably go with creating a fresh new instance and 
copying over the fresh new field values.


constructValue is entirely different than this default value. 
It's not being put into the database, it's just for the library 
to send it when it's missing. (so other apps accessing the 
database can't use the same info) - It's also still an open 
question if it even gives any value because it isn't part of the 
DB.


To support constructValues I iterate over all DB fields and run 
their constructors. I implemented listing the fields with a 
ListFields!T template. However now when I want to generate the DB 
field information I also use this same template to list all 
columns to generate attributes, such as what default value to put 
into SQL. Problem here is that that tries to call the 
constructor, which wants to iterate over the fields, while the 
fields are still being iterated. (or something similar to this)


Basically in the end the compiler complained about forward 
reference / the size of the fields not being known when I put in 
a field of a template type that would try to use the same 
ListFields template on the class I put that value in.


Right now I hack around this by adding an `int cacheHack` 
template parameter to ListFields, which simply does nothing. 
However this fixes that the compiler thinks the template isn't 
usable and everything seems to work with this.


Anyway this is all completely different from the default value 
thing, because I already found workarounds and changed some 
internals a bit to support things like cyclic data structures.


I would still like a way to access the initializer from class 
fields, and it would be especially cool would be to know if they 
are explicitly set. Right now I have this weird and heavy 
`@defaultValue(...)` annotation that's basically the same as `= 
...;`, that I just needed to add to make it possible to use 
T.init as default value in the DB as well, but not force it. My 
code uses `@defaultFromInit` to make it use the initializer, but 
it would be great if I didn't need this at all. (although because 
of my cyclic template issues it might break again and be unusable 
for me)


Re: Getting the default value of a class member field

2022-12-01 Thread WebFreak001 via Digitalmars-d-learn

On Thursday, 1 December 2022 at 23:02:31 UTC, kinke wrote:

On Thursday, 1 December 2022 at 08:09:05 UTC, WebFreak001 wrote:
[...]

AFAIK, there is no way. Unlike a struct's init symbol, a class' 
one doesn't necessarily represent a valid instance state - it's 
just the raw payload before invoking a ctor (which constructs a 
valid instance), and the state 'dead' memory is reset to after 
finalizing an object instance (to prevent dead pointers keeping 
other GC refs alive).


If the ctor worked at CTFE, one could use:
```d
int get() {
scope x = new X;
return x.x;
}
enum bla = get();
```
to get the `x` value of a *valid* instance, which might be 
different than the static initializer (if modified in the ctor).


I guess the main question is why do you require the static 
initializers of these fields at compile-time. 
`__traits(initSymbol)` was added to aid in manual blitting at 
runtime.


I want to use the static initializers (when used with an UDA) as 
default values inside my SQL database.


See 
https://github.com/rorm-orm/dorm/blob/a86c7856e71bbc18cd50a7a6f701c325a4746518/source/dorm/declarative/conversion.d#L959


With my current design it's not really possible to move it out of 
compile time to runtime because the type description I create 
there gets serialized and output for use in another program (the 
migrator). Right now it's simply taking the compile time struct I 
generate and just dumping it without modification into a JSON 
serializer.


I might be abusing classes a little bit here, but they provide 
the easiest way to do a variety of things:
- `is(T : Model)` and especially type specialization like `void 
foo(T : Model)(T x)` is much easier to write and use
- it basically allows me to inject methods into my type (using 
template parameter `this This` I can even get my real type)
- it's the most easy and pretty to type for the user. A struct 
with `mixin Model` would be quite verbose imo and doesn't allow 
Model to define custom fields easily, because they would break 
the implicitly generated constructor


Getting the default value of a class member field

2022-12-01 Thread WebFreak001 via Digitalmars-d-learn

I've got this class definition:

```d
class X
{
this()
{
assert(false);
}

int x = 3;
}
```

due to internal reasons the constructor would fail at compile 
time, so I put in an assert(false) here, and I can't add or 
change any methods in X.


How do I get `3` if I have `X` and field name `"x"` at compile 
time?


For structs `X.init.x` / `__traits(getMember, X.init, "x")` would 
work, however for classes it complains about null dereference.


I saw there is __traits(initSymbol), however that one doesn't 
work at compile time.


Re: DORM - a new D ORM

2022-12-01 Thread WebFreak001 via Digitalmars-d-announce

On Thursday, 1 December 2022 at 06:53:59 UTC, singingbush wrote:
On Thursday, 24 November 2022 at 06:19:24 UTC, WebFreak001 
wrote:

Hello!

at our hackerspace we have been working tirelessly for the 
past half year to bring a great new ORM experience to D and 
Rust.


Is there likely to be support for MS-SQL Server and Oracle in 
the future?


MS-SQL is possible because the underlying SQL library we use 
(sqlx) supports it, but we didn't implement the SQL syntax for 
this yet and we don't really have it on our to-do list right now.


Other than the supported SQLite, MySQL, PostgreSQL and 
potentially MS-SQL I can't promise any support though.


Oracle MySQL should work or do you mean some other database?

If you have any real use-case for them feel free to open an issue 
though.


Re: How do I _really_ implement opApply?

2022-11-29 Thread WebFreak001 via Digitalmars-d-learn

note: all of these functions are prefixed with `scope:`


How do I _really_ implement opApply?

2022-11-29 Thread WebFreak001 via Digitalmars-d-learn
it seems now when trying to cover scope semantics, @safe/@system 
and pure it already becomes quite unmanagable to implement 
opApply properly.


Right now this is my solution:

```d
private static enum opApplyImpl = q{
   int result;
   foreach (string key, ref value; this.table) {
  result = dg(key, value);
  if (result) {
 break;
  }
   }
   return result;
};

public int opApply(scope int delegate(string,   ref   
TOMLValue) @safe   dg)  @safe  { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref const 
TOMLValue) @safe   dg)  @safe  { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref   
TOMLValue) @safe   dg)  @safe  { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const 
TOMLValue) @safe   dg)  @safe  { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref const 
TOMLValue) @safe   dg)  @safe const{ 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const 
TOMLValue) @safe   dg)  @safe const{ 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref   
TOMLValue) @safe   pure dg) @safe pure { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref const 
TOMLValue) @safe   pure dg) @safe pure { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref   
TOMLValue) @safe   pure dg) @safe pure { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const 
TOMLValue) @safe   pure dg) @safe pure { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref const 
TOMLValue) @safe   pure dg) @safe pure const   { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const 
TOMLValue) @safe   pure dg) @safe pure const   { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref   
TOMLValue) @system dg)  @system{ 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref const 
TOMLValue) @system dg)  @system{ 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref   
TOMLValue) @system dg)  @system{ 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const 
TOMLValue) @system dg)  @system{ 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref const 
TOMLValue) @system dg)  @system const  { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const 
TOMLValue) @system dg)  @system const  { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref   
TOMLValue) @system pure dg) @system pure   { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref const 
TOMLValue) @system pure dg) @system pure   { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref   
TOMLValue) @system pure dg) @system pure   { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const 
TOMLValue) @system pure dg) @system pure   { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string,   ref const 
TOMLValue) @system pure dg) @system pure const { 
mixin(opApplyImpl); }
public int opApply(scope int delegate(string, scope ref const 
TOMLValue) @system pure dg) @system pure const { 
mixin(opApplyImpl); }

```

Surely there is a better way to do this?!

Better formatted:

![formatted code](https://wfr.moe/f6PQlp.png)

(note: I don't want to use a template, this way of writing it has 
the advantage that the compiler checks all different code paths 
for errors, so the errors aren't delayed until someone actually 
tries to iterate over my data structure)


DORM - a new D ORM

2022-11-23 Thread WebFreak001 via Digitalmars-d-announce

Hello!

at our hackerspace we have been working tirelessly for the past 
half year to bring a great new ORM experience to D and Rust. The 
D side of this ORM can be found at:


https://code.dlang.org/packages/dorm

It provides a nice D API to directly save data to any database, 
restore data, list data, etc.


Current features:

- Declarative table/model definitions from D, with rich UDA 
annotations
- Command Line Interface to create migrations automatically from 
the D application, good for checking into the source repository 
and to distribute with the app
- Migrations allow both users and developers to update the 
database in their deployed app instances when needed, coming from 
any (or no) previous version

- High-level APIs both in D and Rust
- Support for MySQL, PostgreSQL and sqlite3 (MySQL and PostgreSQL 
drivers written in safe Rust)

- Automatic mapping between defined D datatypes and SQL
- Support for slim SQL queries by only using and selecting 
columns that are needed
- CRUD interface with support for dereferencing foreign keys, 
embedded structs, advanced SQL conditions that can represent 
almost any SQL condition using D code that looks similar to 
regular if statements

- Support for transactions
- Raw SQL API
- Streaming SQL responses (range interface)
- Async support with vibe.d - also works standalone with and 
without multithreading from the application

- Multithreaded connection pool

Documentation can be found here: https://rorm.rs/ (although very 
WIP still!)


Minimal sample project:
https://github.com/rorm-orm/dorm/tree/ee221e6c66bf460b77592c208d1620a93a007a66/testapp

Bunch of integration tests, that show all the functionality:
https://github.com/rorm-orm/dorm/tree/ee221e6c66bf460b77592c208d1620a93a007a66/integration-tests

Feel free to try it out and open issues! The API will probably 
still change a bunch in the future. However the current modelling 
capabilities should already suffice for a wide selection of apps 
you might want to test this in.


Looking forward to your feedback.


Re: Call for action: Easily improve D's ecosystem - DUB documentation improvements

2022-11-14 Thread WebFreak001 via Digitalmars-d-announce
Additional things that are quite low priority, but might be 
interesting for anyone who is looking to contribute on the tech 
side:


- auto-testing what's written in the docs is probably a good 
idea. Ideally by extracting the markdown, but not required. 
Should test whole dub packages
- D source code could be validated for syntax and output (e.g. 
using https://code.dlang.org/packages/md)
- auto-deployment is still missing, GitHub pages and actions 
could be used with this (especially interesting for PRs)
- dead link detection is probably gonna be useful soon 
(awesome-dlang has a GitHub actions workflow for this, could 
reuse that)
- "Run in online IDE" button for code using run.dlang.io would be 
useful - can use single file packages there.


Call for action: Easily improve D's ecosystem - DUB documentation improvements

2022-11-14 Thread WebFreak001 via Digitalmars-d-announce

Hello everyone,

I have been working on revamped DUB docs, which should help users 
with adoption of D, with DUB being basically the package manager 
everyone uses. I have deployed the current state here:


https://docs.webfreak.org/

However a lot of pages are still empty and this is quite a bunch 
of work writing. I don't think it's best if only one person looks 
over all of this, so I'm looking for feedback from the community. 
Here is how you can help:


## Read the docs

Open as many issues as you need about any misunderstandings you 
have or submit PRs for typos.


There are quite a lot of pages already, they were all written 
with varying quality, so fact-checking, proof-reading and quality 
control would be very much appreciated here. (especially for 
things that have been written at 3 AM)


You could even learn new things about DUB quite easily here! The 
docs currently cover all the source code.dlang.org content + lots 
of additional in-depth information that you would usually only 
get by reading the source code or trying things out a lot.


## Write the docs

Check out the issues: 
https://github.com/WebFreak001/dub-docs-v2/issues


A lot of pages, or parts of pages, might be quite trivial to 
regular dub users, so I would love if any of you out there could 
help write pages here.


Here is how you can write docs:

- (Basic) you can just edit the markdown files and optionally 
also view them with any markdown viewer of your choice, this 
might not work that well for recipe content or code examples 
though.
- (Advanced) if you have Python3 installed, you can build the 
Markdown docs into the nice HTML website you can see hosted 
above. Basically you just install the dependencies and can then 
run `mkdocs serve` to have an auto-reloading page whenever you 
make edits. This is a very comfortable way to write docs. See 
[project README](https://github.com/WebFreak001/dub-docs-v2) for 
more details


## Make things clearer

No text is perfect, a lot of this is also written in bulk, with 
relatively quick typing and at times not too much thinking. If 
you spot anything that is unclear or could be better with a 
rewording, feel free to open an issue or make a PR.


## Completing content

Like above, if you spot anything that is missing or incomplete, 
feel free to write the docs immediately or write parts of them 
and open a PR with them. You might also just wanna comment on the 
issues on GitHub with what other ideas you have to put on each 
page or make your own issues for larger things.


## Voting on what to work on

If you don't have the time to work on documentation, I would 
appreciate if you could at least take a minute to vote for your 
favorite content on GitHub. There are issues for nearly each page 
on GitHub already, just react to the opening post with a thumbs 
up, to give it more visibility in the search sorting. (when 
applied) - If you have another minute, don't forget to write what 
especially you want to see or what to see changed!


For bigger things, feel free to open your own issues as well.

## Outlining

A lot of documents are still completely empty. I have made issues 
on GitHub to describe what I thought could be put on each page, 
but haven't yet put any headers or content on most of these 
pages. If you want to help decide on what goes on the page, feel 
free to just add markdown headings (`# Page title`, `## Subtitle 
1`, `### Subtitle 2`) to create empty skeletons for anyone to 
write in it. I think this is quite a low effort thing to work on, 
that's however very useful to give ideas how the content could 
look like and be structured.


---

Even if you have only a very basic understanding of DUB, there is 
a good chance there are still empty sections you can fill with 
your knowledge - check the issues. Each issues has a list of 
bullet-points that would probably be a good idea to be put in the 
document. In the smallest increments you could for example add 
anywhere from only a single bullet point at a time or a full 
document all at once.


Usually more content is better for this brainstorming and writing 
phase, we can always remove or summarize unnecessary / duplicate 
content in the future.


I hope there are some of you out there who can help with this 
project, I think this project is quite an important, but not that 
overly complex, task that many people here can help with.


I think this is quite a low risk, high return thing to be working 
on, which just still needs a bunch of work to be doing.


---

So, because you made it this far into the post - first of all 
thank you for taking the time to read this and any interest you 
may have.


Here are the links again that you might be interested in:

- Issues, sorted by most thumbs up: 
https://github.com/WebFreak001/dub-docs-v2/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc

- Repository: https://github.com/WebFreak001/dub-docs-v2
- Current docs preview: https://docs.webfreak.org/
- Reference to the 

Re: Inochi2D - Realtime 2D Animation written in D

2022-09-11 Thread WebFreak001 via Digitalmars-d-announce

On Sunday, 11 September 2022 at 23:00:24 UTC, Luna wrote:
Hey folks, I have for the (almost) past 2 years been working on 
a real-time 2D animation library called 
[Inochi2D](https://github.com/Inochi2D/inochi2d) and tooling 
for it. Recently I went full time on the project due to 
generous donations on GitHub Sponsors and Patreon.


The library and tooling is mostly implemented in D, with the 
only exception being SDL2, OpenGL and Dear Imgui being used in 
the tooling for the UI.


The project allows you to create and rig segmented 2D art (akin 
to Live2D inc.'s Cubism product) for animation. Allowing you to 
animate the model in real-time either using face tracking [eg. 
with the Inochi Session 
tool](https://github.com/Inochi2D/inochi-session) or more 
traditional animation methods. This kind of tooling is often 
used in games as well as for 
[VTubing](https://en.wikipedia.org/wiki/VTuber), a kind of 
entertainment art form where people use real-time 2D animated 
puppets as their avatars for livestreaming.


I'm planning to release an update for [Inochi 
Creator](https://github.com/Inochi2D/inochi-creator), the tool 
used to rig and animate Inochi2D puppets, on October 10th.


You can also find Inochi Creator and Inochi Session on itch.io:
 * [Inochi 
Creator](https://lunafoxgirlvt.itch.io/inochi-creator)
 * [Inochi 
Session](https://lunafoxgirlvt.itch.io/inochi-session) (Will 
eventually come to Steam too!)


this is an awesome project! I hope to see more people start on 
projects like these or help contribute to them. I definitely 
think projects like these are the kind of thing that D really 
needs.


I love having some graphic thing with concrete use-case and 
target audience, actually writing a real app and helping users do 
what they want to do. I like Inochi2D in particular because it's 
a highly creative thing to do VTubing, all the way from drawing 
characters and rigging them to giving them life in motion and 
personality by the person playing the character. It's things like 
this that inspire people to dig deeper, improve technology and 
make improvements to all layers of an application. (users here 
are potentially improving D, improving Inochi, improving the 
general state of the art in VTubing technology)


I wish you a lot of luck with getting your project to new heights 
and the next big update. It's a very cool project.


I saw you had a GitHub sponsors page as well as Patreon, for 
anyone else in this thread I think it's definitely worth checking 
these out ^^


Re: Initial release of newxml done!

2022-09-11 Thread WebFreak001 via Digitalmars-d-announce

On Friday, 9 September 2022 at 22:00:42 UTC, solidstate1991 wrote:

https://github.com/ZILtoid1991/newxml/releases/tag/v0.2.0

It's a heavily modified `std.experimental.xml` with the 
following changes:


[...]


awesome! got some documentation or examples anywhere? Can't 
really seem to find how to use it really, but will definitely be 
useful when I do stuff with xml.


Re: New WIP DUB documentation

2022-08-16 Thread WebFreak001 via Digitalmars-d-announce

On Tuesday, 16 August 2022 at 08:13:08 UTC, Sönke Ludwig wrote:
Looking good, having SDL+JSON on the same page is especially 
nice and something I've been wanting to fix for a while. Also 
definitely a good idea to use a static generator now that the 
documentation is separate.


One question, though - do you generate the CLI documentation 
from the DUB sources, or is that manual work?


for the CLI documentation I modified the man generator to output 
markdown instead of man formatting, still need to PR that


New WIP DUB documentation

2022-08-15 Thread WebFreak001 via Digitalmars-d-announce
Hi all, I'm currently working on new revamped DUB documentation, 
check it out if you want, it currently contains most old 
documentation plus a big bunch of new documentation:


https://docs.webfreak.org/

Repository: https://github.com/WebFreak001/dub-docs-v2

Instead of being based on diet templates and needing to be 
compiled using `dmd` and build all of vibe.d, it now uses 
[mkdocs](https://www.mkdocs.org/) with a customized [mkdocs 
material theme](https://squidfunk.github.io/mkdocs-material/), so 
now the documentation is Markdown based, which should be more 
familiar to a lot of people + it has a great offline search index 
and a bunch of interactive elements, that also work without JS.


The dub.json and dub.sdl documentation is now merged on the same 
page, where you can simply swap between them whenever you like. 
If you have JS enabled it will also sync it across the entire 
page and persist across page loads.


Writing the docs is really quite easy, you can have it locally be 
served by first installing the dependencies using


```
pip install -r requirements.txt
```

and then when working on it running

```
mkdocs serve
```

to have auto-updating docs in the browser. (auto refresh whenever 
you change anything)


So if you find any typos or want to complete the docs, feel free 
to open a PR on https://github.com/WebFreak001/dub-docs-v2


I plan to have easily discoverable edit links linked on the page 
soon too, which should theoretically just be a simple mkdocs 
configuration thing that's probably already implemented.


Someone from the community has already contributed a dark theme 
to it. :)


[![new dub documentation preview 
screenshot](https://wfr.moe/f6fgF7.png)](https://docs.webfreak.org)


Re: Supporting Arabic in GUI

2022-08-08 Thread WebFreak001 via Digitalmars-d-learn

On Monday, 8 August 2022 at 00:23:52 UTC, pascal111 wrote:

On Monday, 8 August 2022 at 00:20:53 UTC, pascal111 wrote:

On Monday, 8 August 2022 at 00:12:07 UTC, Emanuele Torre wrote:

[...]
So, the reason is the toolkit. I guessed D has specific 
library for GUI, and with that I judged D as whole that if it 
supports Arabic or not.



[...]
I mean "my own time" that I'm still studying D basics, so I'll 
study GUI programming at another time, but if there are 
available resources for GUI, I would like to take a look in 
'em.


EDIT: The last part of my previous post is lost. I'll retype it 
again with some changes.


I mean with time "my own time" that I'm studying D basic now, 
but if there are resources for GUI in D, I would like to take a 
look in 'em.


there is https://gtkdcoding.com/ if you want to use GtkD


Re: How do I initialize a templated constructor?

2022-08-08 Thread WebFreak001 via Digitalmars-d-learn

On Monday, 8 August 2022 at 05:38:31 UTC, rempas wrote:

In the following struct (as an example, not real code):

```
struct TestArray(ulong element_n) {
  int[element_n] elements;

  this(string type)(ulong number) {
pragma(msg, "The type is: " ~ typeof(type).stringof);
  }
}
```

I want to create it and be able to successfully initialize the 
template parameters
of the constructor but until now, I wasn't able to find a way 
to successfully do

that. Is there a way you guys know?  I have tried the following:

```
void main() {
  // Doesn't work
  auto val = TestArray!(10, "int")(60);

  // Doesn't work either
  auto val = TestArray!(10).TestArray!("int")(60);

  // Neither this works
  auto val = TestArray!(10).this!("int")(60);
}
```

As with every question I make, the solution must be "betterC" 
compatible so I can use it.

Thanks a lot!


I would move the constructor out of the struct into a helper 
function, either global or as a static member:


```d
TestArray!n testArray(ulong n, string type)(ulong number) {
TestArray!n ret;
pragma(msg, "The type is: " ~ typeof(type).stringof);

ret.something = something; // do your constructor logic here

return ret;
}
```

which you can then use:

```d
auto t = testArray!(10, "int")(60);
```

As the template parameter being part of the constructor would 
only change the constructor (and can't change anything like types 
outside the ctor) it doesn't have any limitations and if you 
define it in the same module as the struct you can also access 
the private members.


Re: Giving up

2022-08-08 Thread WebFreak001 via Digitalmars-d-announce

On Sunday, 7 August 2022 at 00:59:14 UTC, mw wrote:
On Sunday, 7 August 2022 at 00:54:35 UTC, Steven Schveighoffer 
wrote:


Note, we have a complete copy of the git repository.



So you mean all the dub registered packages are cached 
somewhere?



Can we publish the cache address?


here is a snapshot, but I don't have the constantly updating 
cache exposed anywhere:


https://wfr.moe/clones-2022-06-14_16-16-36_you_might_need_to_git_checkout_master_or_main_in_each_project.tar.zstd

The dependency cloning and updating is part of 
https://github.com/Pure-D/symbol-search which is a complete 
DScanner index of all DUB packages (all symbols indexed with 
version, file and line number + symbol type and other things) 
which is run on my server every 6 hours.


Re: unexpected noreturn behavior

2022-04-21 Thread WebFreak001 via Digitalmars-d-learn
On Thursday, 21 April 2022 at 12:28:37 UTC, rikki cattermole 
wrote:
noreturn is the bottom type which can implicitly convert to any 
type, including void. A value of type noreturn will never be 
produced and the compiler can optimize such code accordingly.


https://dlang.org/spec/type.html#noreturn


ok so I guess all the `isSomething(T)` functions must be written 
like this then:


```d
enum isSomething(T) = !is(immutable T == immutable noreturn)
&& is(T : Something!Other, Other...);
```

which I think is a little bug-prone, but at least that would 
solve my issues.


unexpected noreturn behavior

2022-04-21 Thread WebFreak001 via Digitalmars-d-learn

What would you expect for this code?

```d
struct Something(Types...) {}

enum isSomethingExact(T) = is(T == Something!Types, Types...);
enum isSomething(T) = is(T : Something!Types, Types...);

pragma(msg, isSomethingExact!noreturn);
pragma(msg, isSomething!noreturn);
```

This currently outputs `false`, `true` which breaks my code 
because more concretely `isSumType!(typeof(someMethod()))` 
returns true. I can add a check for noreturn before that, but it 
seems a little weird that noreturn returns true for isSomething!T 
and functions like that in phobos.


Re: PixelPerfectEngine v0.10.0-beta.5 : Now with a synth

2022-02-23 Thread WebFreak001 via Digitalmars-d-announce
On Wednesday, 23 February 2022 at 21:07:25 UTC, solidstate1991 
wrote:

https://github.com/ZILtoid1991/pixelperfectengine/releases/tag/v0.10.0-beta.5

After I created my own IO library that has audio features that 
are easier to interoperate with D code (iota), I decided to 
finish up my phase modulation (often sold as either frequency 
modulation or phase distortion too by some brands, with minor 
tweaks to the underlying math to avoid patent infringement) 
synthesizer for my game engine. This one uses a simplified math 
with fixed-length wavetables (can be user supplied too), highly 
configurable envelops, and has up to 16 voice polyphony if 2 
operator mode is used for all channels (8 if channels are 
combined). It can even do resonant waveforms with some tricks 
(modulating a sine wave with a triangle wave).


[...]


nice! Any example to play around with?


Re: The DIID series (Do It In D)

2022-01-28 Thread WebFreak001 via Digitalmars-d-announce
On Thursday, 27 January 2022 at 23:56:55 UTC, Ola Fosheim Grøstad 
wrote:

On Thursday, 27 January 2022 at 08:52:32 UTC, WebFreak001 wrote:
the list is being maintained, feel free to open PRs to update 
links and remove old stuff.


It is probably better that the current maintainers remove 
stuff, I think people would get upset if someone else started 
to wipe out projects that haven’t recieved updates in a year or 
that are just not ready for consumption.


I don't think that's the case - just open a PR removing old 
stuff, the maintainers will check that the links are indeed old 
and no longer necessary or they will tell you that it's kept 
because of reason XYZ.


If there are people that would get upset from removing it, it's 
something that shouldn't be removed. (as there are people who are 
still interested in the project and might still use it)


Re: The DIID series (Do It In D)

2022-01-27 Thread WebFreak001 via Digitalmars-d-announce
On Wednesday, 26 January 2022 at 15:53:44 UTC, Ola Fosheim 
Grøstad wrote:
On Wednesday, 26 January 2022 at 13:14:49 UTC, Guillaume Piolat 
wrote:
Precisely I opened this thread because it's hard to know about 
everything that exist in the D ecosystem. I expected tips for 
this or that library.


Is this list out of date?

https://github.com/dlang-community/awesome-d

Anyway, the short examples you provide is a good format. Full 
tutorials can often be too time consuming…


the list is being maintained, feel free to open PRs to update 
links and remove old stuff.


Re: passing a variadic parameter to randomSample

2022-01-25 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 25 January 2022 at 09:48:25 UTC, forkit wrote:
so I'm trying to write (or rather learn how to write) a 
'variadic template function', that returns just one of its 
variadic parameter, randomly chosen.


But can't get my head around the problem here :-(

.. Error: template `std.random.randomSample` cannot deduce 
function from argument types `


// --

module test;
import std;

string RandomChoice(R...)(R r)
{
auto rnd = MinstdRand0(42);
return r.randomSample(1, rnd).to!string;
}

void main()
{
writeln( RandomChoice("typeA", "typeB", "typeC") );
}

// --


On Tuesday, 25 January 2022 at 09:48:25 UTC, forkit wrote:
so I'm trying to write (or rather learn how to write) a 
'variadic template function', that returns just one of its 
variadic parameter, randomly chosen.


But can't get my head around the problem here :-(

.. Error: template `std.random.randomSample` cannot deduce 
function from argument types `


// --

module test;
import std;

string RandomChoice(R...)(R r)
{
auto rnd = MinstdRand0(42);
return r.randomSample(1, rnd).to!string;
}

void main()
{
writeln( RandomChoice("typeA", "typeB", "typeC") );
}

// --


With R... each value could be of different type, so passing 
`RandomChoice("typeA", 4)` would break the current code.


I think there are 2 different ways that can solve this elegantly:

1) restrict the parameters to all be the same parameter type:

```d
string RandomChoice(T)(T[] r...)
{
auto rnd = MinstdRand0(42);
return r.randomSample(1, rnd).to!string;
}
```

and code compiles with no changes. Instead of using 
.to!string you could also return the parameter type itself if you 
want to get the value itself:


```d
T RandomChoice(T)(T[] r...)
{
auto rnd = MinstdRand0(42);
return r.randomSample(1, rnd).front;
}
```

2) generate a random number between 0 and `r.length`, add a 
switch case and dynamically generate a case for each number 
(static foreach) and return the processed value using .to!string:


```d
string RandomChoice(R...)(R r)
{
auto rnd = MinstdRand0(42);
switch (uniform(0, R.length, rnd))
{
static foreach (i, value; r)
{
case i: // this code is duplicated for each 
parameter
	// use this if you want to support different 
argument types

return value.to!string;
}
default: assert(false);
}
}
```


Re: How to create a function that behaves like std.stdio.writeln but prepends output with __FILE__:_LINE_

2022-01-25 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 25 January 2022 at 12:27:16 UTC, Dennis wrote:

On Tuesday, 25 January 2022 at 12:11:01 UTC, JG wrote:
Any ideas how one can achieve what is written in the subject 
line?


```D
void f(T...)(auto ref T args, string file = __FILE__, int line 
= __LINE__)

{
writeln(file, ":", line, ": ", args);
}
```


note: default arguments after variadic arguments are supported 
since D 2.079.0: 
https://dlang.org/changelog/2.079.0.html#default_after_variadic


Re: passing a variadic parameter to randomSample

2022-01-25 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 25 January 2022 at 09:48:25 UTC, forkit wrote:
so I'm trying to write (or rather learn how to write) a 
'variadic template function', that returns just one of its 
variadic parameter, randomly chosen.


But can't get my head around the problem here :-(

.. Error: template `std.random.randomSample` cannot deduce 
function from argument types `


// --

module test;
import std;

string RandomChoice(R...)(R r)
{
auto rnd = MinstdRand0(42);
return r.randomSample(1, rnd).to!string;
}

void main()
{
writeln( RandomChoice("typeA", "typeB", "typeC") );
}

// --


With R... each value could be of different type, so passing 
`RandomChoice("typeA", 4)` would break the current code.


I think there are 2 different ways that can solve this elegantly:

1) restrict the parameters to all be the same parameter type:

```d
string RandomChoice(T)(T[] r...)
{
auto rnd = MinstdRand0(42);
return r.randomSample(1, rnd).to!string;
}
```

and code compiles with no changes. Instead of using 
.to!string you could also return the parameter type itself if you 
want to get the value itself:


```d
T RandomChoice(T)(T[] r...)
{
auto rnd = MinstdRand0(42);
return r.randomSample(1, rnd).front;
}
```

2) generate a random number between 0 and `r.length`, add a 
switch case and dynamically generate a case for each number 
(static foreach) and return the processed value using .to!string:


```d
string RandomChoice(R...)(R r)
{
auto rnd = MinstdRand0(42);
switch (uniform(0, R.length, rnd))
{
static foreach (i, value; r)
{
case i: // this code is duplicated for each 
parameter
	// use this if you want to support different 
argument types

return value.to!string;
}
default: assert(false);
}
}
```


Re: All Community Discord channels are now being bridged to Matrix

2022-01-21 Thread WebFreak001 via Digitalmars-d-announce

On Friday, 21 January 2022 at 03:18:09 UTC, Jack wrote:

On Saturday, 15 January 2022 at 18:45:15 UTC, WebFreak001 wrote:

[...]


why are you guys using matrix over discord?


it's bridged - we support both and most are using discord, but we 
want to have matrix work just as well.


All Community Discord channels are now being bridged to Matrix

2022-01-15 Thread WebFreak001 via Digitalmars-d-announce
After having tried out the Matrix bridge for a while and Spaces 
now being properly released in the Matrix spec and starting to 
become available in clients, we have now bridged all the Discord 
rooms to Matrix rooms.


The Matrix space is accessible via 
[#dlang:m.wfr.moe](https://matrix.to/#/#dlang:m.wfr.moe) or if 
your Matrix client does not yet support the spaces feature you 
can join the individual rooms by browsing the `m.wfr.moe` Room 
Directory.


The bridge is now also self-hosted and limited to just the D 
discord, so it's a lot quicker than the previous solution, 
although the previous solution is still in place for the existing 
channels and will be migrated later.


![matrix screenshot](https://wfr.moe/f6iZwQ.png)


Re: Error message formatter for range primitives

2022-01-11 Thread WebFreak001 via Digitalmars-d-announce
On Wednesday, 5 January 2022 at 09:32:36 UTC, Robert Schadek 
wrote:
In 
https://forum.dlang.org/post/tfdycnibnxyryizec...@forum.dlang.org I complained
that error message related to range primitives like 
isInputRange, especially on

template constraints, are not great.

[...]


cool!

As I'm not a fan of needing to refactor code I made my first DMD 
PR to try to make it possible to include this in phobos here: 
https://github.com/dlang/dmd/pull/13511


```d
source/app.d(43,5): Error: template `app.fun` cannot deduce 
function from argument types `!()(Sample1)`

source/app.d(22,6):Candidates are: `fun(T)(T t)`
  with `T = Sample1`
  must satisfy the following constraint:
`   isInputRange!T: Sample1 is not an InputRange because:
the function 'popFront' does not exist`
source/app.d(24,6):`fun(T)(T t)`
  with `T = Sample1`
  must satisfy the following constraint:
`   isRandomAccessRange!T: Sample1 is not an 
RandomAccessRange because

the function 'popFront' does not exist
and the property 'save' does not exist
and must allow for array indexing, aka. [] access`
```


Re: fixedstring: a @safe, @nogc string type

2022-01-11 Thread WebFreak001 via Digitalmars-d-announce

On Tuesday, 11 January 2022 at 11:16:13 UTC, Moth wrote:

On Tuesday, 11 January 2022 at 03:20:22 UTC, Salih Dincer wrote:

[snip]


glad to hear you're finding it useful! =]

hm, i'm not sure how i would go about fixing that double 
character issue. i know there's currently some wierdness with 
wchars / dchars equality that needs to be fixed [shouldn't be 
too much trouble, just need to set aside the time for it], but 
i think being able to tell how many chars there are in a glyph 
requires unicode awareness? i'll look into it.


[...]


you can relatively easily find out how many bytes a string takes 
up with `std.utf`. You can also iterate by code points or 
graphemes there if you want to translate some kind of character 
index to byte position.


HOWEVER it's not clear what a character is. Sure for the posted 
cases here it's no problem but when it comes to languages based 
on combining glyphs together to form new glyphs it's no longer 
clear what is a character. There are Graphemes (grapheme 
clusters) which are probably the closest to what everybody would 
think a character is, but IIRC there are edge cases with that a 
programmer wouldn't expect, like adding a character not 
increasing the count of characters of the string because it 
merges with the last Grapheme. Additionally there is a 
performance impact on using Graphemes over simpler things like 
codepoints which fit 98% of use-cases with strings. Codepoints in 
D are mapped 1:1 using dchar, take up to 2 wchars or up to 4 
chars. You can use `std.utf` to compute byte lengths for a 
codepoint given a string.


I would rather suggest you support FixedString with types other 
than `char`. (wchar, dchar, heck users could even use any 
arbitrary type and use this as array class) For languages that 
commonly use more than 1 byte per codepoint or for interop with 
Win32 unicode APIs, JavaScript strings, C# strings, UTF16 files 
in general, etc. programmers might opt to use FixedString with 
wchar then.


With D's templates that should be quite easy to do (add a 
template parameter to the struct like `struct FixedString(size_t 
maxSize, CharT = char)` and replace all usage of char in your 
code with `CharT` in this case)


Re: Printing a quoted string

2022-01-02 Thread WebFreak001 via Digitalmars-d-learn

On Sunday, 2 January 2022 at 17:27:53 UTC, Amit wrote:

Hi!

I would like to print a string in the same format that I would 
write it in the code (with quotes and with special characters 
escaped). Similar to [Go's %q 
format](https://pkg.go.dev/fmt#hdr-Printing). Is there a safe, 
built-in way to do that?


For example:

```
string s = "one \"two\"\nthree four";
writeln(/* ??? */);
```

And get as output

```
"one \"two\"\nthree four"
```

Instead of

```
one "two"
three four
```


as a hack I always do:
```d
writeln([s]);
```
because arrays get serialized like D strings, there will be 
additional `[` and `]` though.


Sample output:
```
["Hello there \"uwu\" ``\x1B[Dabc\n"]
```


Re: How to gets multi results using tuple in D?

2021-12-23 Thread WebFreak001 via Digitalmars-d-learn

On Thursday, 23 December 2021 at 08:33:17 UTC, zoujiaqing wrote:


C++ Code:
```cpp
std::tuple DoIt()
{
return {false, 0, 0, "Hello"};
}

auto [r1, r2, r3, r4] = DoIt();

if (r1 == false)

```


D Code:

```D
Tuple!(bool, int, int, string) DoIt()
{
return [false, 1, 1, "Hello"];
}

auto result = DoIt();

auto r1= result[0];
auto r2= result[1];
auto r3= result[2];
auto r3= result[3];

if (r1 == false)
```

D requires more lines of code.


I think this is the best thing you can do:

```d
bool r1;
int r2, r3;
string r4;
AliasSeq!(r1, r2, r3, r4) = DoIt();
```

https://forum.dlang.org/thread/kmugmwmduxeoyfffo...@forum.dlang.org


Re: what the closest thing we have to racket's check_expect()?

2021-12-22 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 22 December 2021 at 20:14:01 UTC, Dr Machine Code 
wrote:
it differ from assert because it contains the expression, file 
and line information. See this 
https://stackoverflow.com/questions/14420857/check-expect-example-in-racket
what's the closest thing we have in D? can we make it without 
compiler  builtin?


if you just want to use an assert, the compiler flag 
`-checkaction=context` basically gives you this kind of error 
messages.


Example how to use in DUB (from serve-d): 
https://github.com/Pure-D/serve-d/blob/84094fade433f3d52e43c5296d20af53b102ffdd/dub.json



```d
void main()
{
assert(1 + 1 == 2);
assert(1 + 1 == 1);
}

__EOF__

Sample output:

core.exception.AssertError@onlineapp.d(4): 2 != 1

??:? _d_assert_msg [0x563912072788]
./onlineapp.d:4 _Dmain [0x563912069f54]
```

[Run Online](https://run.dlang.io/is/X1bevb)


Re: How to define property type to Array!struct?

2021-12-15 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 11:36:41 UTC, Manfred Nowak 
wrote:

On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote:
[...]
Alternatively, remove the template `()` from your `struct 
Header`


What is the semantic sense of a template having no parameters?

Although the documentation declares such a template to be 
syntactically correct, not a single example suggests a meaning.


For functions there is a use-case: they will not be 
compiled/included in the executable until they are actually 
instantiated once.


Additionally for functions that means for libraries they aren't 
usually compiled into the resulting library file, unless they are 
used in the library themself. (only really meaningful when you 
don't distribute the D source or when interoping with other 
languages)


For types similarly, if you have any template instantiations 
inside your templated type, they will not be instantiated or 
compiled, until that template is used at least once in code 
anywhere.


So:
```d
struct Header()
{
Appender!string name;
}
```
unless Appender!string is used anywhere else in the code, that 
Appender struct will never be initiated, thus no member functions 
will be emitted or compile time will be used, until you 
instantiate the Header struct once.


Re: Immutability and arrays

2021-12-14 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 14 December 2021 at 08:44:02 UTC, rumbu wrote:
I am trying to understand why in this two different cases 
(Simple and Complex), the compiler behaviour is different.


```d
struct SimpleStruct { int x;}
struct ComplexStruct { int[] x; }

void main()
{
SimpleStruct[] buf1;
immutable(SimpleStruct)[] ibuf1;
buf1[0 .. 10] = ibuf1[0 .. 10];
//this works

ComplexStruct[] buf2;
immutable(ComplexStruct)[] ibuf2;

buf2[0 .. 10] = ibuf2[0 .. 10];
//error cannot implicitly convert expression `ibuf2[0..10]` 
of type `immutable(ComplexStruct)[]` to `ComplexStruct[]`

}
```


there are special cases in the compiler for values that have no 
mutable indirections: 
https://dlang.org/spec/const3.html#implicit_qualifier_conversions


Values that have no mutable indirections (including structs 
that don't contain any field with mutable indirections) can be 
implicitly converted across mutable, const, immutable, const 
shared, inout and inout shared.


so that first struct may be implicitly converted between 
mutable/immutable/const because it doesn't contain any mutable 
indirections (mutable arrays/pointers/references)


Re: How to define property type to Array!struct?

2021-12-14 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 14 December 2021 at 08:12:04 UTC, zoujiaqing wrote:

My code:

```D
module http.HttpRequest;

import std.container;
import std.array : Appender;

struct HttpRequest
{
struct Header()
{
Appender!string name;
Appender!string value;
}

string method;
string uri;
int versionMajor = 0;
int versionMinor = 0;
Array!Header headers;
ubyte[] content;
bool keepAlive = false;
}
```

Error code:
```D
source/http/HttpRequest.d(18,5): Error: struct 
`std.container.array.Array` does not match any template 
declaration

```


the problem is that your header is a template, so you need to 
instantiate it:

```d
Array!(Header!()) headers;
```

the error message is kinda poor here.

Alternatively, remove the template `()` from your `struct Header`


Re: A debug class has started

2021-12-14 Thread WebFreak001 via Digitalmars-d-learn

On Monday, 13 December 2021 at 22:43:14 UTC, forkit wrote:

[...]

//char* w = cast(char*)str; // nope. a pointer to a string 
constant is
// (supposed to be) immutable, 
so expect undefined behaviour.


note:


//char* w = cast(char*)str.toStringz; // also ok


this is also undefined behavior (toStringz returns an 
immutable(char)* which you cast away)



char* w = strdup(cast(char*)str); // ok


this is a C library function - this is risky if your string is 
not a string literal (may copy too much or segfault) - I would 
recommend not using this. This will only work properly when you 
have string literals (strings that are created using `""` in 
code, no other strings like those that are for example read from 
user input, from files or dynamically created)



//char* w = cast(char*)str.dup; // also ok
//char* w = str.dup.ptr; // also ok

[...]


the last two here are equivalent, I personally prefer the last 
one. I think these are the idiomatic way how to duplicate a 
string into writable memory and get the pointer to it.


The best way would be not doing this at all - when you manipulate 
strings/arrays in D you can do so by just assigning the elements 
like this:


```d
immutable(char)[] replaceChar(char[] str, char ch1, char ch2)
{
for (ulong i = 0; i < len; i++)
{
if (str[i] == ch1)
{
writefln("Found %c at str[%d]", ch1, i); // fine
str[i] = ch2;
}
}

return str.idup;
}
```

then when you call it:
```d
replaceChar(str.dup, ';', 'X');
```

or the function more idiomatically:
```d
string replaceChar(scope char[] str, char ch1, char ch2)
{
// ref makes the `c` variable an l-value / assignable and 
modifies the character when assigned

foreach (i, ref c; str)
{
if (c == ch1)
{
writefln("Found %s at str[%s]", c, i);
c = ch2;
}
}

return str.idup; // you could also not .idup and return 
char[] and let the caller .idup it when needed

}
```

You only really need to work with pointers when you interface 
with a C library that needs them.


Re: A debug class has started

2021-12-13 Thread WebFreak001 via Digitalmars-d-learn

On Monday, 13 December 2021 at 11:09:18 UTC, drug wrote:

On 13.12.2021 13:49, forkit wrote:

On Monday, 13 December 2021 at 09:49:05 UTC, forkit wrote:




char* w = cast(char*)str.toStringz; // this seems to be the 
solution


class has ended ;-)


That's because `str` is initialized by a literal and you can 
not change it by definition. When you call `toStringz` it 
duplicates that literal (adding terminating zero at the end) 
and the duplicate is mutable. I would recommend do not use 
`toStringz` and just make duplicate of the literal - 
https://run.dlang.io/is/vaosW0


important: toStringz _may_ do a copy with the current 
implementation but nothing in the docs states it actually does 
so. In fact there is commented out code where it [in the 
past](https://github.com/dlang/phobos/commit/bc412e7c3fa3f124d7f2785223318b45edd4b3e6#diff-b94766ba288f9b4b05ef1a4874e26724750e614afdcddaf4c2071d0f19d91595L217) just dereferenced the memory after the string and checked if it was 0.


You should really use `.dup` if you want to mutate your string. 
(You would need to duplicate anyway if you don't want an unsafe 
cast)


pro-tip for bugs like this: just slap `@safe:` at the start of 
every file, the compiler will tell you everything that is risky 
and the bug will 9/10 times just sort itself out by fixing what 
the compiler complains about. (just recently helped someone with 
this again, was a 3 minute fix for a big code-base where manually 
searching the issue would have taken much longer)


Re: D + Qt + QtDesigner

2021-11-21 Thread WebFreak001 via Digitalmars-d-announce

On Sunday, 21 November 2021 at 15:08:18 UTC, MGW wrote:

I am still developing my QtE5 library.
Unfortunately, I don't have enough free time to make it into a 
complete dub package.


Link to short video: http://www.youtube.com/watch?v=TFN5P4eoS_o


this is really neat! Do you have some code for us to play around 
with?


Re: code-d 0.23.0

2021-11-21 Thread WebFreak001 via Digitalmars-d-announce

On Sunday, 21 November 2021 at 00:58:50 UTC, zjh wrote:
On Saturday, 20 November 2021 at 17:57:40 UTC, WebFreak001 
wrote:

Hi everyone,


Can `VIM` be supported? Many programmers program with `VIM`.


serve-d (the underlying LSP server) is supported with ycmd: 
https://github.com/Pure-D/serve-d/blob/master/editor-vim.md


You can also search for other LSP clients for your editor if you 
don't like ycmd, it should work with any of them.


Re: code-d 0.23.0

2021-11-20 Thread WebFreak001 via Digitalmars-d-announce

On Saturday, 20 November 2021 at 18:29:00 UTC, Andre Pany wrote:
On Saturday, 20 November 2021 at 17:57:40 UTC, WebFreak001 
wrote:

Hi everyone,

I just released a new version of my Visual Studio Code 
extension "code-d"


[...]


Thank you so much for your work on this extension.

By chance, do you consider to make your extension compatible 
for vscode.dev ?


Kind regards
Andre


vscode.dev might take some work to get working properly. 
Meanwhile you can already use gitpod.io, there is also a template 
here: https://github.com/Pure-D/code-d-gitpod (though it needs 
some updating now)


code-d 0.23.0

2021-11-20 Thread WebFreak001 via Digitalmars-d-announce

Hi everyone,

I just released a new version of my Visual Studio Code extension 
"code-d"


The last release was 2 years ago so really it will feel like a 
brand new extension to everyone who has only used the stable 
serve-d release (and not nightly or beta) before.


Along with usual updates and improvements to DCD, DScanner and 
dfmt this release comes with:


- single file editing support
- New walkthrough & compiler installer for new users (installing 
D has never been easier before!)

- Updated auto completion UI (big thanks to RUSshy)
- new smart snippets
- much improved debugging support
- project building improvements
- error/linting improvements
- new auto fix suggestions
- better integration of D-Scanner
- better integrated ddoc viewer
- new highlight provider
- workspace trust support (run serve-d securely in untrusted 
workspaces)


...and much more

get it now for VSCode from

https://marketplace.visualstudio.com/items?itemName=webfreak.code-d
https://open-vsx.org/extension/webfreak/code-d
https://github.com/Pure-D/code-d/releases/tag/v0.23.0

Fun fact: in a week is code-d's 6th Birthday, meaning I nearly 
had this project ongoing for a quarter of my life now, lol


If you are not a VSCode user, this release also did a new stable 
release for serve-d, so other LSP compatible editors (there are 
new guides in the repository) can be used as well.


See https://github.com/Pure-D/serve-d


Re: Make sure lifetime of helper structs is less than owning struct

2021-11-15 Thread WebFreak001 via Digitalmars-d-learn
On Monday, 15 November 2021 at 19:24:56 UTC, Sebastiaan Koppe 
wrote:

On Monday, 15 November 2021 at 15:56:57 UTC, WebFreak001 wrote:

is this currently possible or maybe possible with DIP1000?


Yes it is. But besides `-dip1000` and `@safe`, it requires the 
use of a pointer:


```D
@safe:

struct ByChunk {
FileReader* r;
void popFront() {}
}

struct FileReader {
ByChunk byChunk() return scope {
return ByChunk();
}
}

void main() {
ByChunk helper;
{
auto file = FileReader();
	helper = file.byChunk;  // Error: address of variable 
`file` assigned to `helper` with longer lifetime

}
helper.popFront;
}
```


awesome, such a simple solution! Also saves me the pain of 
copying the struct data and avoiding copy constructor and stuff 
by using a pointer.


Make sure lifetime of helper structs is less than owning struct

2021-11-15 Thread WebFreak001 via Digitalmars-d-learn
I have an API with some struct like a file reader. I want to add 
byChunks-like functionality to it, so I'm trying to implement it 
with a helper struct that implements opApply. I have disabled 
copying the file reader struct because it cleans up the resources 
once it goes out of scope, however now I need to temporarily save 
the resources in the helper struct to be able to read from it.


How can I make sure that the foreach helper struct (and with that 
the copies of the resources) cannot be used once the owning 
struct goes out of scope?


```d
ByChunk helper;
{
auto file = FileReader(x);
helper = file.byChunk;
}
helper.popFront; // crash - I want the compiler to disallow this
```

is this currently possible or maybe possible with DIP1000?


Re: __cpuid like in C

2021-11-02 Thread WebFreak001 via Digitalmars-d-learn

On Monday, 1 November 2021 at 16:16:12 UTC, Arsium wrote:

On Monday, 1 November 2021 at 16:02:20 UTC, Paul Backus wrote:

On Monday, 1 November 2021 at 16:00:05 UTC, Arsium wrote:

Hello,

Currently, I'm working to implement myself WinAPI functions. 
However, I could not find anything matching with  : __cpuid 
like : https://gist.github.com/boxmein/7d8e5fae7febafc5851e


Any idea ?


Not sure if it's exactly the same, but there is 
[`core.cpuid`][1].


[1]: https://druntime.dpldocs.info/core.cpuid.html


Oh thx my bad I did not see it!


if you want even more cpuid details there is also

https://github.com/dd86k/ddcpuid/
https://code.dlang.org/packages/ddcpuid


Re: sha3-d

2021-10-29 Thread WebFreak001 via Digitalmars-d-announce

On Friday, 29 October 2021 at 15:13:38 UTC, dd wrote:

Hello all!

When I submitted my work to Phobos[1] earlier this year, it was 
rejected. (Understandably)


So I made a DUB package and forgot to announce it here!

Package: https://code.dlang.org/packages/sha3-d
Source: https://github.com/dd86k/sha3-d

[1] https://github.com/dlang/phobos/pull/7713


Awesome! Haven't had the need to use SHA-3 yet myself, but given 
all the other growing ecosystems where this could be of use it's 
nice to have this high-performance implementation already.


Would be cool having benchmarks comparing this to other 
implementations if great performance is a goal, as you already 
mentioned in your README it's much faster than keccack-tiny.


Re: TimeoutException for connecting to MySQL using a hunt-entity.

2021-10-22 Thread WebFreak001 via Digitalmars-d-learn

On Friday, 22 October 2021 at 11:42:34 UTC, greenbyte wrote:

Hi, all!

I use the hunt-entity library to work with MySQL. I get the 
hunt.Exceptions.TimeoutException: "Timeout in 30 secs" when 
trying to connect. I configured MySQL and ran the code from the 
instructions https://github.com/huntlabs/hunt-entity


MySQL:
mysql Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - 
GPL)


DUB:
version 1.25.0, built on Apr 23 2021

In dub.json enabled "hunt-entity": "~>2.7.3"


From the error message you posted it seems like it's failing to 
connect. Did you check that the IP address and port you are 
connecting to are correct? In case of localhost, try 127.0.0.1 
instead of "localhost"


Using GTK's GResources with GtkD with DUB

2021-10-21 Thread WebFreak001 via Digitalmars-d-announce

I just want to push my blog again :p

https://new.webfreak.org/blog/2021-10/21/GTKD-GResources-with-dub

You would want to use this for example when you make a GTK app 
that you want to add custom icons into. Using GResources will 
make it search your executable for the icon first.


Also this makes you not dependent on the filesystem for 
resources, everything is bundled in your executable.


There are also some hints and links how to use GTK4 and 
LibAdwaita if you didn't know yet.


Re: D Language Foundation Monthly Meeting Summary (September 24, 2021)

2021-10-19 Thread WebFreak001 via Digitalmars-d-announce

On Tuesday, 19 October 2021 at 16:17:43 UTC, Andrea Fontana wrote:

On Wednesday, 6 October 2021 at 06:23:01 UTC, WebFreak001 wrote:

On Friday, 1 October 2021 at 12:32:20 UTC, Mike Parker wrote:

[...]
new slogan
[...]


want to generate controversial heat?

Do it in D (DIID)

(careful with there being a trademark for DiiD though)


You mean:

Just D it


That's awesome! using that as my discord status now.


Re: DMD Frontend working in WebAssembly

2021-10-15 Thread WebFreak001 via Digitalmars-d-announce

On Thursday, 14 October 2021 at 22:56:07 UTC, hatf0 wrote:

Hi all,

I've just managed to get the full DMD front-end to work in 
WebAssembly (with skoppe's druntime fork). This doesn't do 
code-gen or anything (but it potentially could?), and has some 
OS-specific functionality stubbed out. No clue about GC -- 
haven't run into that issue, haven't thought about it yet!


You can find my work here if you're interested: 
https://github.com/hatf0/dmd-fe-wasm-wrapper


This repo also serves as a semi-decent guide on how to get 
started building files that target WebAssembly (specifically 
WASI), if you're into that.


neat! Given the low footprint of WASM apps maybe this could maybe 
be used to have small isolated, cross-platform DMD tools that run 
one-shot? Could for example run the WASM binaries from the IDE 
and because it's WASM running in the own process, with memory 
that we can free, it avoids low startup times, especially on 
windows.


Do we have some WASM runner in D?


Re: New library: argparse, for parsing CLI arguments

2021-10-13 Thread WebFreak001 via Digitalmars-d-announce
On Wednesday, 13 October 2021 at 16:24:52 UTC, Steven 
Schveighoffer wrote:

On 10/13/21 11:50 AM, Andrey Zherikov wrote:

On Wednesday, 13 October 2021 at 14:36:30 UTC, Steven [...]


No, it's not a confusion about `unused`. The `array` parameter 
has the same issue.


I meant that for named parameters, one shouldn't have to 
attribute them for them to be considered part of the parameters.


e.g. (to replace your current code):

```d
struct Params
{
// Positional arguments are required by default
@PositionalArgument(0) // override the default of a named 
argument

string name;

// Named argments are optional by default
string unused = "some default value";

// Numeric types are converted automatically
int num;

// Boolean flags are supported
bool flag;

// Enums are also supported
enum Enum { unset, foo, boo };
@NamedArgument("enum") // required since enum is a keyword
Enum enumValue;

// Use array to store multiple values
int[] array;

// Callback with no args (flag)
void cb() {}

// Callback with single value
void cb1(string value) { assert(value == "cb-value"); }

// Callback with zero or more values
void cb2(string[] value) { assert(value == 
["cb-v1","cb-v2"]); }

}
```

The point is that I shouldn't have to tell the library the name 
of something that I've already given a name to.


Having them named differently on the command line than the 
actual field name should still be a possibility (and required 
in some cases, e.g. the `enum` case above), but honestly, the 
`Params` struct exists solely to accept command line 
parameters, there's no compelling need to use alternate names 
for the command line and the field name. If the library 
automatically does the right thing by default, then your code 
becomes simpler and more beautiful.


Not to detract from your library, because I think it's an 
awesome design to model using structs (one I use all the time), 
but the API developer in me frowns at lack of DRY. Try to focus 
on requiring the smallest amount of machinery/attributes 
possible. Every time you require extraneous pieces to get 
things to work, it adds another place where errors/confusion 
can happen.


-Steve


This should probably rather be:


```d
struct Params
{
// Positional arguments are required by default
@PositionalArgument(0) // override the default of a named 
argument

string name;

// Named argments are optional by default
@NamedArgument
string unused = "some default value";

// Numeric types are converted automatically
@NamedArgument
int num;

// Boolean flags are supported
@NamedArgument
bool flag;

// Enums are also supported
enum Enum { unset, foo, boo };
@NamedArgument("enum") // required since enum is a keyword
Enum enumValue;

// Use array to store multiple values
@NamedArgument
int[] array;

// Callback with no args (flag)
@NamedArgument
void cb() {}

// Callback with single value
@NamedArgument
void cb1(string value) { assert(value == "cb-value"); }

// Callback with zero or more values
@NamedArgument
void cb2(string[] value) { assert(value == 
["cb-v1","cb-v2"]); }

}
```

as otherwise the definition could be ambiguous (like are the 
parameters positional with automatic count or named by default?)


If you don't like the repetition you could also then make it 
`@NamedArgument { [all my variables] }` But I'm not a fan of 
having everything included even without UDA


Re: New library: argparse, for parsing CLI arguments

2021-10-13 Thread WebFreak001 via Digitalmars-d-announce
On Wednesday, 13 October 2021 at 12:11:03 UTC, Andrey Zherikov 
wrote:
On Wednesday, 13 October 2021 at 11:59:06 UTC, WebFreak001 
wrote:
On Wednesday, 13 October 2021 at 11:27:40 UTC, Andrey Zherikov 
wrote:

[...]
It also doesn't depend on anything besides the standard 
library.

[...]


if you want to drop the dependency on std.typecons : Nullable 
you could use https://code.dlang.org/packages/expected, where 
you can additionally return error values with instead of 
returning null on error.


Doesn't cast to bool but can check for .hasError which is more 
explicit.


This will break "doesn't depend on anything besides std" 
unfortunately.


well... if you ask me that expected package should be part of the 
stdlib, it has decent download statistics too :p


At least would be better than creating your own Result type if 
you do decide to drop Nullable for something with error 
information I think


Re: tkd does not build anymore after 2.096

2021-10-13 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 13 October 2021 at 02:03:30 UTC, rikki cattermole 
wrote:
The repo itself hasn't been archived as of this writing. So a 
PR may succeed.


But yeah the guy is gone by the looks.

If he is willing this could be a possible candidate for moving 
it to dlang-community although it'll need someone to shepherd 
it.


https://github.com/nomad-software/tkd


it was archived but isn't anymore. Migrating it to 
dlang-community would be a good idea I think, but idk if it's 
needed having a maintainer for it. Having more people who have 
push access would at least be better for managing PRs and issues 
than having it archived though.


Re: New library: argparse, for parsing CLI arguments

2021-10-13 Thread WebFreak001 via Digitalmars-d-announce
On Wednesday, 13 October 2021 at 11:27:40 UTC, Andrey Zherikov 
wrote:

[...]
It also doesn't depend on anything besides the standard library.
[...]


if you want to drop the dependency on std.typecons : Nullable you 
could use https://code.dlang.org/packages/expected, where you can 
additionally return error values with instead of returning null 
on error.


Doesn't cast to bool but can check for .hasError which is more 
explicit.


Re: Better debugging?

2021-10-04 Thread WebFreak001 via Digitalmars-d-learn

On Sunday, 3 October 2021 at 22:27:20 UTC, Tim wrote:

On Sunday, 3 October 2021 at 22:26:15 UTC, Imperatorn wrote:

On Sunday, 3 October 2021 at 22:21:45 UTC, Tim wrote:

[...]


You don't say which operating system you are using.
I usually use Visual D which works great imo.

If I use vscode I use the C++ debug extension (don't remember 
what it's called).


If I debug outside of the IDE I use WinDbg, also has source 
debug support if configured correctly.


If you are on Linux I'm not sure, but I would go for the C++ 
thing probably.


Apologies. I use KDE linux


On Linux I would recommend compiling with LDC (dub defaults to 
debug mode, otherwise use `-g`) and using LLDB.


Additionally for string, array and AA support use 
https://github.com/Pure-D/dlang-debug/#lldb (code-d section in 
README is for upcoming release, you need to follow the manual 
install procedures)


For VSCode I recommend using the 
[CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) extension, it works pretty well.


Re: GtkD Coding Post #0115 - GKT/GIO Application - Open Files from the Command Line

2021-09-29 Thread WebFreak001 via Digitalmars-d-announce

On Friday, 24 September 2021 at 13:23:22 UTC, Ron Tarrant wrote:
Another new GtkD Coding blog post, this time it's about how to 
deal with the HANDLES_OPEN flag. You can find it here: 
https://gtkdcoding.com/2021/09/24/0115-gtk-gio-app-open-flag.html


nice. Do you think you could make a GTK 4 tutorial eventually? 
Would be great if it uses libadwaita, could make linux phone 
mobile apps with it.


Re: Using D "rocket" logo in outside presentation

2021-09-29 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 29 September 2021 at 04:24:13 UTC, Chris Piker 
wrote:

Hi D

I'm to give a presentation to a combined NASA/ESA group in a 
few hours and would like to include a copy of the D "rocket" 
logo when mentioning new server side tools that I've written in 
D.  Is such use of this particular [D 
logo](https://i0.wp.com/dlang.org/blog/wp-content/uploads/2021/08/logo_256.png?w=750=1) permissible?


Thanks,


it's [Attribution-ShareAlike 4.0 International (CC BY-SA 
4.0)](https://creativecommons.org/licenses/by-sa/4.0/) so it's 
freely usable (give appropriate credit, dunno if saying it's the 
D logo is enough credit giving, but don't think I have seen that 
artwork been used with any other credit in context of dlang 
before)


see https://github.com/dlang-community/artwork


Re: Piping from terminal into D program

2021-09-04 Thread WebFreak001 via Digitalmars-d-learn

On Saturday, 4 September 2021 at 15:41:51 UTC, eXodiquas wrote:

Hello everyone,

I created a small little D program that reads in a string from 
the command line and shuffles the letters of the nouns a bit 
around. This is pretty straight forward, but what I see now 
happening is a bit strange, at least for me.


I am reading the args out of the main function arguments.

```d
void main(string[] args) {
  args.writeln();
}
```

this works fine whenever I call the program like 
`./nounscramble "Hello, my name is Earl!"` the string shows up 
in `args[1]`. But when I call `echo "Hello, my name is Earl!" | 
./nounscramble` it does not show up in the args array, the only 
thing showing up is the name of the executable (which is 
expected).


My question is now, can someone explain what I am doing wrong? 
Maybe I misunderstood the pipe in Linux systems and it is 
obvious for someone who knows how this works exactly, or maybe 
D works differently with pipes and I havn't found the correct 
documentation.


Thanks in advance. :)

eXodiquas


to extend on Brian Tiffin's reply, you can read from the standard 
input stream (the data piped to your program) using std.stdio's 
`stdin`


Example:

```d
import std.stdio;
foreach (line; stdin.byLine)
writeln("got input line: ", line);
// IMPORTANT: the line buffer is reused (it's a char[], not a 
string), so if you want to store it in a variable outside the 
foreach, use .idup to make it a string (that is not changed when 
leaving the loop)

```

or

```d
import std.stdio;
foreach (chunk; stdin.byChunk(1024))
writeln("got input chunk: ", cast(char[])chunk);
// same warning as above, don't case to string (that's unsafe and 
wouldn't be allowed in @safe code, but casting to char[] is safe, 
as it explicitly says it can be changed)

```

or

```d
import std.stdio;
ubyte[1024] buffer;
auto part = cast(char[])stdin.rawRead(buffer[]);
writeln("got part: ", part);
// this is the lower level equivalent of the byChunk above, it's 
just doing a single step instead of multiple chunks, so you 
control when it is changed.
// a slice of this buffer (which is what the return value is) 
needs to be .idup'd to be persisted outside the lifetime of the 
`buffer` variable

```


Re: dmdtags 1.0.0: an accurate tag generator for D source code

2021-08-27 Thread WebFreak001 via Digitalmars-d-announce

On Friday, 27 August 2021 at 22:01:59 UTC, Dennis wrote:

On Friday, 27 August 2021 at 21:38:58 UTC, Paul Backus wrote:
Editors that support tags files, such as Vim and Emacs, can 
use this index to help with things like project navigation and 
tab completion.


Cool! Now I'll have to look if I can make this work with Visual 
Studio Code, since code-d which uses Dsymbol tends to be 
unreliable, and this looks ideal for Phobos / Druntime symbol 
completion.


actually it uses D-Scanner and should be a fairly easy drop-in 
replacement.


I'm just worried about how the memory usage will grow with this, 
considering dmd never frees. Maybe I should make it run as 
external tool instead of a library so the OS cleans up, but for 
that get a performance penalty especially on Windows.


Re: scope(exit) with expected library

2021-08-25 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 15:30:57 UTC, Steven 
Schveighoffer wrote:

[...]

Another approach is to let the compiler deal with the error 
handling and not muddy your return type. Swift does something 
similar, where it rewrites the throw/catch into a standard 
return and doesn't do actual thrown exceptions. There are some 
caveats, but if we could fit this kind of error handling into 
mostly-similar syntax (i.e. the same ease of exceptions without 
the actual problems that exceptions and stack unwinding bring), 
it might make things much easier to transition.


-Steve


I like the Swift error handling, so I think this would be a great 
idea for nothrow code with error handling too.


Re: scope(exit) with expected library

2021-08-25 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 14:52:34 UTC, Steven 
Schveighoffer wrote:

On 8/25/21 10:42 AM, Steven Schveighoffer wrote:



I think it's possible to work with some mechanics that aren't 
necessarily desirable. Something like:




One has to weigh how much this is preferred to actual exception 
handling...


If something like DIP1008 could become usable, it might 
alleviate even the need for such things.


-Steve


DIP1008 is a nice step forward, but I think sometimes explicit 
error handling is nicer, and especially with C interop and 
concurrency (like vibe.d tasks) `nothrow` is pretty good to have.


Re: scope(exit) with expected library

2021-08-25 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 14:42:07 UTC, Steven 
Schveighoffer wrote:

On 8/25/21 10:22 AM, Paul Backus wrote:
On Wednesday, 25 August 2021 at 14:04:54 UTC, WebFreak001 
wrote:

[...]


Probably the only principled way to make this work would be to 
define some kind of "concept"/structural interface that's 
recognized by the compiler to mean "this is an error-handling 
type", in the same way that the compiler recognizes 
`empty`/`front`/`popFront` to mean "this is an iterable type".


Even then, it would require some pretty invasive language 
changes (and some pretty gnarly code in the compiler), but 
it's at least *theoretically* possible.


I think it's possible to work with some mechanics that aren't 
necessarily desirable. Something like:


```d
ErrorHandler error = registerErrorHandler;
error.onFailure({writeln("division failed");});
error.onSuccess({writeln("division succeeded");});

...
```

On returning `err`, the registration would trigger a flag 
saying an error is occurring, and call the right callback when 
`ErrorHandler` is destructing. The cleanup of the return value 
would clean up the error condition. It would be messy and 
likely brittle.


Hm I'm not quite seeing how the error handler is related to an 
"Expected type interface" that the compiler could expect.


Currently with exceptions the scope things are implemented using 
try-catch-finally, this would be even simpler:


```d
scope(exit) exit();
scope(success) success();
scope(failure) failure();

return something();
```

lowers to

```d
auto ret = something();
if (ret.isError) failure();
if (!ret.isError) success();
exit();
return ret;
```

for all return statements.

I might be missing some obvious drawbacks here but I think this 
sounds reasonable and comparable with the try-catch-finally 
lowering.


As Paul Backus suggested the compiler could check if the return 
type has for example `is(typeof(return.isError) : bool)` and 
maybe also if the function is `nothrow`.


Re: Emacs AutoComplete Tutorial Video for D Language

2021-08-25 Thread WebFreak001 via Digitalmars-d-learn

On Monday, 23 August 2021 at 17:59:44 UTC, Mahdi wrote:
I made this video for people asking how to configure Dlang in 
Emacs environment:) :


https://peertube.linuxrocks.online/w/62pWpmw2r4Se1XvmYiWm75


cool, I think you might wanna post this in General or Announce 
instead so more people see it!


Though I think it would be useful having this as text form as 
well, which is probably a bit better suited for a setup like 
this. A text tutorial accompanied with the video may also allow 
you to cut out big text sections from the video.


Personally I think it would be best if there was speech in your 
video as well. I saw you are non-English, you could actually use 
this as an advantage. There are much less D resources in 
non-English languages, making a tutorial in your own native 
language could allow more people to learn and discover D.


Re: scope(exit) with expected library

2021-08-25 Thread WebFreak001 via Digitalmars-d-learn

On Wednesday, 25 August 2021 at 14:22:26 UTC, Paul Backus wrote:

On Wednesday, 25 August 2021 at 14:04:54 UTC, WebFreak001 wrote:

[...]


Probably the only principled way to make this work would be to 
define some kind of "concept"/structural interface that's 
recognized by the compiler to mean "this is an error-handling 
type", in the same way that the compiler recognizes 
`empty`/`front`/`popFront` to mean "this is an iterable type".


Even then, it would require some pretty invasive language 
changes (and some pretty gnarly code in the compiler), but it's 
at least *theoretically* possible.


do you think this would be worth a DIP that could get in? Or 
should usage in these packages grow first?


scope(exit) with expected library

2021-08-25 Thread WebFreak001 via Digitalmars-d-learn
Would it be possible to extend `scope(exit)` and `scope(success)` 
to trigger properly for functions returning `Expected!T` as 
defined in the 
[expectations](https://code.dlang.org/packages/expectations) and 
[expected](https://code.dlang.org/packages/expected) DUB 
libraries?


For example is it possible to make this work as expected:
```d
Expected!int divide(int a, int b) nothrow
{
scope (failure) writeln("division failed");
scope (success) writeln("division succeeded");

if (b == 0) return err!int("division by zero");
return ok(a / b);
}
```


Re: Vibe.d error

2021-08-23 Thread WebFreak001 via Digitalmars-d-learn

On Friday, 20 August 2021 at 17:39:29 UTC, JG wrote:

On Friday, 20 August 2021 at 10:50:12 UTC, WebFreak001 wrote:

On Wednesday, 18 August 2021 at 19:51:00 UTC, JG wrote:

[...]


There might be incompatibilities with how openssl is used and 
the installed openssl version or config.


If you are getting this from having https enabled on the 
server, I would recommend instead switching to HTTP-only and 
using a reverse proxy such as with nginx or caddy to serve it 
with HTTPS.


Thank you very much for your reply. Yes, we are getting this 
with HTTPS enabled. May I ask why you suggest not to use HTTPS?


I think you might need to restart the server whenever you update 
the SSL certificates + in every app you need to pass in your SSL 
certificate location somehow or hardcode it, which if you make 
all your apps yourself you can do consistently, but otherwise 
creates inconsistencies which can be hard to maintain.


On the other hand if you use a single reverse proxy like with 
nginx or caddy for all the HTTPS services it can reload them all 
at once and use the same config for everything. Additionally the 
are better supported by ACME services like LetsEncrypt or ZeroSSL 
through built-in plugins, etc.


But most importantly: these services have undergone much more 
testing for security than vibe.d, so you can generally expect it 
to be less likely to have critical bugs in API usage.


Re: Vibe.d error

2021-08-20 Thread WebFreak001 via Digitalmars-d-learn

On Wednesday, 18 August 2021 at 19:51:00 UTC, JG wrote:

Hi,

We are intermittently getting the following error:
Accept TLS connection: server
OpenSSL error at ../ssl/record/rec_layer_s3.c:1543: 
error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert 
certificate unknown (SSL alert number 46)
HTTP connection handler has thrown: Accepting SSL tunnel: 
error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert 
certificate unknown (336151574)
Full error: 
object.Exception@/home/jg/.dub/packages/vibe-d-0.9.3/vibe-d/tls/vibe/stream/openssl.d(578): Accepting SSL tunnel: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown (336151574)



Anyone have any idea what might cause this?


There might be incompatibilities with how openssl is used and the 
installed openssl version or config.


If you are getting this from having https enabled on the server, 
I would recommend instead switching to HTTP-only and using a 
reverse proxy such as with nginx or caddy to serve it with HTTPS.


Re: Registering-unregistering threads

2021-08-01 Thread WebFreak001 via Digitalmars-d-learn

On Friday, 30 July 2021 at 23:48:41 UTC, solidstate1991 wrote:
I'm doing some audio-related work, and one thing I need is to 
unregister from (and maybe later temporarily re-register to) 
the GC, since it would cause some issues, and it would be nice 
if I still could use the GC during disk operations, etc.


Info on it is quite scarce and a bit confusing. If I unregister 
from the RT, will that mean it'll be GC independent, or will 
have other consequences too?


There is an idiom on d-idioms that probably fits what you needs: 
https://p0nce.github.io/d-idioms/#The-impossible-real-time-thread


Additional documentation:
- 
https://github.com/dlang/druntime/blob/c3a4c51773e88c68dc3efa73335befdb74d17242/src/core/thread/threadbase.d#L827
- 
https://github.com/dlang/druntime/blob/078cb3cdafda875a9893574fc53437908f3dfd26/src/core/thread/osthread.d#L1267


Re: D compiler equivilent of "gcc -E" for debug/view template instantiation(generated) code?

2021-07-30 Thread WebFreak001 via Digitalmars-d-learn

On Friday, 30 July 2021 at 06:00:41 UTC, dangbinghoo wrote:
hi, is there any D compiler option or other method to view the 
final template instantiation but not compiled (in asm or 
binary) code?


if there's a way, it might be very usefull for newbies like me 
to learn and understand the the Meta programming of dlang.




thanks!

dbh


Not sure if this is exactly what you want but there is a hidden 
switch in dmd called `-vcg-ast` that prints out all the templates 
instantiated.


On run.dlang.io you can use the "AST" button to view this 
conveniently online.


Re: Yurai - Full Stack Web Framework (Diamond MVC Successor)

2021-07-07 Thread WebFreak001 via Digitalmars-d-announce

On Wednesday, 7 July 2021 at 08:32:16 UTC, bauss wrote:

[...]

I'm very happy with the result so far and just initially 
published it now.


[...]


Awesome!

Do you think it's in a usable state yet?

I think for Diamond it would have been nice to have more 
tutorials / documentation - do you think this new framework will 
have more?


I might try it out for my next project.


Matrix bridge trial run

2021-07-01 Thread WebFreak001 via Digitalmars-d-announce
The D language code club community discord chat server is 
currently doing a trial run of bridging our Discord server to a 
Matrix chat "Space".


The spaces feature in Matrix features a lot of similarities to 
Discord servers and maps very well with a list of rooms. We have 
linked a few rooms to test out the bridging capabilities.


If you haven't joined the Discord Server because you don't want 
to use their proprietary app, you might like to use Matrix 
instead. The spaces feature is available in the Element app once 
you enable the Spaces beta in your settings.


Once you have enabled Spaces in your settings you can join the 
space and automatically its linked rooms using


```
/join 
https://matrix.to/#/!HDxtVdRNEKXjLPrWDg:m.wfr.moe?via=m.wfr.moe=matrix.org

```

alternatively if you don't want to join the whole space or have 
an incompatible client, you can also join the rooms one-by-one, 
currently this includes the following room IDs:


- 
[#dlang-news:m.wfr.moe](https://matrix.to/#/!CGyWJxXAgYflrWgKGQ:m.wfr.moe?via=m.wfr.moe=t2bot.io) (maps to #news in Discord)
- 
[#dlang-questions:m.wfr.moe](https://matrix.to/#/!ruvwTnlYNglSQzDFcd:m.wfr.moe?via=m.wfr.moe=t2bot.io=matrix.org) (maps to #programming in Discord)
- 
[#dlang-random:m.wfr.moe](https://matrix.to/#/!DdYLizavGsezkcGOGR:m.wfr.moe?via=m.wfr.moe=t2bot.io=matrix.org) (maps to #dev_urandom in Discord)
- 
[#dlang-editors:m.wfr.moe](https://matrix.to/#/!uxlVbwjbuqNADarAOd:m.wfr.moe?via=m.wfr.moe=t2bot.io=matrix.org) (maps to #d-editors in Discord)


We are currently using [t2bot.io](https://t2bot.io/discord/) to 
bridge our Discrod channels to Matrix channels, so the service 
stability may not be influenced by us.


If the matrix bridge proves successful, we might extend it with 
all of our rooms on Discord as well once the Spaces feature goes 
out of beta.


Re: How to reset the website when the user leaves it, with vibe.d?

2021-06-29 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 29 June 2021 at 16:25:09 UTC, vnr wrote:

Hello 

I have a bit of a problem that seems simple enough, but I can't 
find an answer to my questions. On my website, I have two 
textareas that the user can write on. When the user reloads the 
page or closes it and then reopens it, the text he wrote is 
still written, which is quite annoying.


So my question is how to reset the website (the page) when the 
user reloads or quits.


I've looked at the vibe.d's sessions, because that's probably 
where the answer to my question lies, but from what I 
understand, it requires a "login and logout form" (at least, 
all the code examples do this), which I don't want, because I 
want the website to be accessible without logging in.


Do you have any ideas on how to fix this, probably with 
sessions?


this is a client behavior that is implemented by some browsers, 
it has nothing to do with vibe.d.


Set autocomplete to off to fix this: 
https://stackoverflow.com/questions/2486474/preventing-firefox-from-remembering-the-input-value-on-refresh-with-a-meta-tag


Re: How to reset the website when the user leaves it, with vibe.d?

2021-06-29 Thread WebFreak001 via Digitalmars-d-learn

On Tuesday, 29 June 2021 at 19:05:43 UTC, WebFreak001 wrote:

[...]


I should add that this is a convenience feature for users and you 
should avoid setting this unless it absolutely doesn't make sense 
that stuff is prefilled for the user.


It's there to keep input in case you accidentally refresh the 
page.





Re: Vibe.d diet templates

2021-06-17 Thread WebFreak001 via Digitalmars-d-learn

On Thursday, 17 June 2021 at 16:26:57 UTC, JG wrote:

[...]

Thanks, this works. I would have thought this would be a common 
enough use case to have support in diet. Anyone else wanted 
this?


Opened an issue here: 
https://github.com/rejectedsoftware/diet-ng/issues/91


Re: Vibe.d diet templates

2021-06-17 Thread WebFreak001 via Digitalmars-d-learn

On Thursday, 17 June 2021 at 08:23:54 UTC, JG wrote:
Suppose I have an array of attributes and values v is there any 
way to apply these attributes to a tag?


So that something like

tag(#{v[0]0]}=#{v[0][1]},...})

becomes



where v[0][0]="attribute0" and v[0][1]="value0"?


I think there is nothing for this built-in in diet, so you have 
to manually emit raw HTML:


```diet
- import std.xml : encode;
- auto start = appender!string;
- start ~= "

Re: Financial Library

2021-06-14 Thread WebFreak001 via Digitalmars-d-learn

On Sunday, 13 June 2021 at 12:46:29 UTC, Financial Wiz wrote:
What are some of the best Financial Libraries for D? I would 
like to be able to aggregate as much accurate information as 
possible.


Thanks.


if you want a type-safe money handling type, try 
https://code.dlang.org/packages/money


It's well documented, has straightforward code and does just 
what's advertised. It's also hosted on the dlang-community 
organization on GitHub, so it's easily possible to take over 
ownership if the project author disappears.


Re: Schroedinger's Ranges

2021-06-03 Thread WebFreak001 via Digitalmars-d-learn

On Thursday, 3 June 2021 at 00:39:04 UTC, vacuum_tube wrote:
I've been trying to make a struct for CSV parsing and 
manipulating.  The code was as follows:

```
struct CSVData(bool HeaderFromFirstLine)
{
char[][] header = [];
char[][][] rest = [];

```
[...]


additionally to the other comment, you probably want to use 
`string` (`immutable(char)[]`) instead of char[] here, as you 
want your data to stay the same and not be modified after 
assignment.


If you replace them with `string` and have your code be `@safe`, 
the compiler will tell you where you try to assign your char[] 
data that may be modified and in those cases you would want to 
call `.idup` to duplicate the data to make it persistent.




Re: Atom ide-d package

2021-06-02 Thread WebFreak001 via Digitalmars-d-announce

On Wednesday, 2 June 2021 at 12:09:37 UTC, Amin wrote:

[...]


Awesome! Thanks for maintaining the atom extension using serve-d 
:)




  1   2   3   4   5   >