Re: Error: circular reference to variable cause by order (bugs?)

2024-07-18 Thread monkyyy via Digitalmars-d-learn

On Thursday, 18 July 2024 at 12:25:37 UTC, Dakota wrote:

I am trying to translate some c code into d, get this error:

```d
struct A {
void* sub;
}

struct B {
void* subs;
}

__gshared {
const A[1] a0 = [
{ _ptr },
];
const A[2] a1 = [
{ _ptr },
];
const B b1 = {a1.ptr};
const b1_ptr = 

const A[1] a2 = [
{ _ptr },
];
const B b2 = {a2.ptr};
const b2_ptr = 
}

```

```sh
 Error: circular reference to variable `tests.b1_ptr`
```

If I move `a0` after `b2_ptr`, no error any more.

The c code has circular reference type, and compile ok. and 
there is a lot type I am not able to adjust order by hand to 
guess right order.


the translate code still need to work with C interface, so I 
can not change the struct layout.  is this a bug of d?


if it was a compiler bug it probably be a crash; and the c code 
may have had a header file of some sort to make the linker happy 
that the traslator skipped


that is just confusing cyclic code


Re: Being reading a lot about betterC, but still have some questions

2024-07-09 Thread monkyyy via Digitalmars-d-learn

On Tuesday, 9 July 2024 at 20:03:15 UTC, kiboshimo wrote:

On Tuesday, 9 July 2024 at 14:42:01 UTC, monkyyy wrote:

On Tuesday, 9 July 2024 at 07:54:12 UTC, kiboshimo wrote:
- betterC can be compiled to WASM, but some of phobos can't, 
so basically same worries as above. I'm afraid to lose some 
essential systems stuff that I could not replace.


yes, and your not afraid enough

Really liked the idea of doing it with betterC to start my 
systems programming journey


Theres nothing even slightly pleasant or easy about d's wasm 
"support"; I wrote my own cos, sqrt functions, you get 
*nothing* from phoboes


Writing my own math functions is outside of my range, I still 
have hopes of this not being so hard. So you get another 
opportunity to crush it.


Honestly porting isqrt is easier then trying to get a half baked 
file io to work


but it is *everything* is gone and thats probaly overwhelming 
unless your prepared for it.




You could have used a C library for those things you 
implemented yourself, right? I suppose you didn't because doing 
things is cool, or because C is "not ergonomic" to use as 
foreign code. Because of the quirks. Which would make for a not 
so pleasant experience when writing a small game.


What do you think about using C libraries like that?


wasm *in general* breaks libc's fileio "for safety" (arguably the 
most important part of libc, morons), d's wasm libc in even more 
broken due to it coming out of no where and there being like 3 
guys doing 20 ours of work on the "runtime" or something(ignore 
ppl who say d supports 7 platforms, it supports 2).


While it can be a trivial port, I think you better off sticking 
to the raylib api as your ground layer as whatever work there 
seems to carry over.


Re: Being reading a lot about betterC, but still have some questions

2024-07-09 Thread monkyyy via Digitalmars-d-learn

On Tuesday, 9 July 2024 at 07:54:12 UTC, kiboshimo wrote:

I'm going to try a project with raylib and WASM.


use mine

https://github.com/crazymonkyyy/raylib-2024/blob/master/docs/examplecode.md

- betterC can be compiled to WASM, but some of phobos can't, so 
basically same worries as above. I'm afraid to lose some 
essential systems stuff that I could not replace.


yes, and your not afraid enough

Really liked the idea of doing it with betterC to start my 
systems programming journey


Theres nothing even slightly pleasant or easy about d's wasm 
"support"; I wrote my own cos, sqrt functions, you get *nothing* 
from phoboes


Re: Why does this mixin fail to compile?

2024-07-01 Thread monkyyy via Digitalmars-d-learn

On Monday, 1 July 2024 at 13:00:55 UTC, ryuukk_ wrote:

i don't want string concatenation


This limitation is very intentional, add it to the pile like file 
io in ctfe of stuff that the core devs think "you shouldnt even 
want that" for "safety"


Re: Call an external program from CTFE

2024-06-23 Thread monkyyy via Digitalmars-d-learn

On Sunday, 23 June 2024 at 16:33:54 UTC, realhet wrote:

Hi,

Is there a way to call an external program from CTFE?


Use case:
Inside a module I want to put some GLSL code.
I also want to generate that GLSL code using CTFE.
And when it's done, it would be nice if I was able to save that 
GLSL code into a temp file and call the glsl compiler on it.
The goal is that the compiled version of the module would 
contain also the compiled version of that GLSL shader.
And the time of the GLSL compilation could be the exact same 
time of the EXE compilation.


This sounds a bit of hacking, but from viewing from a 
multi-target build perspective, it can make sense.  Calling a 
compiler from another compiler... Why not? :D


The nearest thing I've found is the "include file contents" 
'macro', that can be enabled with a command line parameter. 
(Maybe it's already deprecated, I'm not sure.)



My other way to do this would be an automation inside my IDE.  
But if something could be done on the language level it's 
always better than doing it by using external tools.


ctfe is intentionally hobbled "for safety"; while theres bugs and 
edge cases I dont think anyone has a sane way to escape to full 
execution


realistically you should just write a build script with two stages

fun thought experiment time, if you found a programmable 
"FUSE"(file system api) database of some sort, mixed `-J` and 
`-mixin`, I think you may be able to call a compiler


Re: How to use D without the GC ?

2024-06-12 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 12 June 2024 at 16:50:04 UTC, Vinod K Chandran 
wrote:

On Wednesday, 12 June 2024 at 01:35:26 UTC, monkyyy wrote:


rather then worring about the gc, just have 95% of data on the 
stack


How's that even possible ? AFAIK, we need heap allocated memory 
in order to make GUI lib as a DLL. So creating things in heap 
and modify it, that's the nature of my project.


gui is a bit harder and maybe aim for 70%

but if you went down the rabbit hole you could have strings be in 
an "arena" of which the first 5000 chars are a global scope 
array; or full me and just an array that doesnt expand


Re: How to use D without the GC ?

2024-06-11 Thread monkyyy via Digitalmars-d-learn

On Tuesday, 11 June 2024 at 17:15:07 UTC, Vinod K Chandran wrote:
On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer 
wrote:



I would instead ask the reason for wanting to write D code 
without the GC.


-Steve


Hi Steve,
Two reasons.
1. I am writting a dll to use in Python. So I am assuming that 
manual memory management is better for this project. It will 
give finer control to me.

2. To squeeze out the last bit of performance from D.


rather then worring about the gc, just have 95% of data on the 
stack


Re: How to generate a random number from system clock as seed

2024-06-09 Thread monkyyy via Digitalmars-d-learn

On Sunday, 9 June 2024 at 07:11:22 UTC, Eric P626 wrote:

On Saturday, 8 June 2024 at 21:04:16 UTC, monkyyy wrote:
generate is a very rare function and do novices understand 
lamdas?


Yes I know lamdas, but try not to use them.

I am not very picky about the exact source of time, I just want 
a different integer every time I run the program. But while 
looking at the doc, it seemed complicated because I required 
time zones, and I could not get the entire time stamp as a 
single integer.


Im not sure exactly why it automagically works, but it does work, 
the defualt rng is time seeded somehow


I am not exactly sure what the exclamation points stand for in 
the first line of code.


templates

its a simplification but assume function headers have two parts, 
a compile time part and a runtime part thats from c; while it 
trys to fill in the compile time part implicitly if theres no 
information and your passing a type in, you use ! to fill the 
compile time header


Re: How to generate a random number from system clock as seed

2024-06-08 Thread monkyyy via Digitalmars-d-learn

On Saturday, 8 June 2024 at 20:53:02 UTC, Nick Treleaven wrote:

On Saturday, 8 June 2024 at 16:09:04 UTC, monkyyy wrote:
rng is an optional parameter, `uniform(0,100).writeln;` alone 
works; the docs not telling you that is really bad


They do tell you:

urng 	(optional) random number generator to use; if not 
specified, defaults to rndGen


That overload is used in the 2nd example.

https://dlang.org/phobos/std_random.html#.uniform


generate is a very rare function and do novices understand lamdas?


Re: How to generate a random number from system clock as seed

2024-06-08 Thread monkyyy via Digitalmars-d-learn

On Saturday, 8 June 2024 at 13:19:30 UTC, Eric P626 wrote:
I managed to create a random number generator using the 
following code:


~~~
auto rng = Random(42);
//
uniform(0,10,rng);
~~~

Now I want to seed the generator using system time. I looked at 
Date & time functions/classes and systime functions/classes. 
The problem is that they all require a time zone. But I don't 
need a time zone since there is no time zone. I just want the 
number of seconds elapsed since jan 1st 1970. In other words, 
the internal system clock value.


rng is an optional parameter, `uniform(0,100).writeln;` alone 
works; the docs not telling you that is really bad


the docs/api for std.time/random are bad if you need something 
specif Id suggest doing it yourself, but if you want to use 
std.time anyway the magic word I think is "localtime"(Ive pounded 
my head into those auto generated docs and had to dive deep to 
find such estoric knowledge)


if you need a spefic random number from a spefic timestamp, Id 
suggest making a rng function from scratch and using clibs time 
stuff


Re: How to make project with main application and cli application in the same folder?

2024-04-21 Thread Monkyyy via Digitalmars-d-learn

On Sunday, 21 April 2024 at 08:44:38 UTC, alex wrote:
Hi guys. Trying to play with vibe-d and want to create separate 
web app, and cli app which can add admin users. When I just 
keep both files app.d and cli.d in source folder, I get an 
error that I can't have more then 1 main function.


[...]


This is the issue that made me quit dub entirely, you'll be told 
"you shouldn'twant that" or very complicated git sub project 
nonsense


I suggest seeing if vibe can be ported to plain d and writing a 
build script


Re: How can I tell D that function args are @nogc etc.

2024-04-13 Thread Monkyyy via Digitalmars-d-learn

On Friday, 12 April 2024 at 03:57:40 UTC, John Dougan wrote:

 Not every day you get to blame a compiler bug.



D is uniquely: hacky, expressive and buggy.

Having more metaprograming then c++ without the raw man power 
comes at a cost, in d you should distrust the spec and instead 
see what the compiler actually does far more then any other 
languge.





-- john


-- monkyyy


Re: Optimization when using a 2-dimensional array of objects

2024-03-22 Thread monkyyy via Digitalmars-d-learn

On Friday, 22 March 2024 at 02:19:07 UTC, Liam McGillivray wrote:
In the [game I am currently 
making](https://github.com/LiamM32/Open_Emblem/blob/master/oe-raylib/source/app.d), I have a `Map` class (actually a combination of an interface & class template, but I'll call it a "class" for simplicity), in which there will probably be only one instance running at a time. In that map class is a 2-dimensional dynamic array of `Tile` objects called `grid`. What these `Tile` objects represent are like squares on a chessboard. Their placement in `grid` represents their location on the map.




```d
enum tile{wall,field}
bool ispassable(tile t)=>...
alias grid_=tile[maxhieght][maxwidth];
grid_ grid;
```
your not simplifying anything here with all them oo terms



Is one option more efficient than the other?


You should probaly do the lazyest thing, factor out your 
"ispassable" logic, like what your walking n of 3, n of 8, n of 
15? so long as you dont do something insane it will be fast on a 
modern computer; allocating several dynamic array that are the 
size of your game world every frame could easily be not very sane.


and if you really really wanted to care, you could precompute the 
"connected compoints" by flood filling across passable tiles with 
a "color" of 0, then finding an empty cell, flood filling with 1, 
etc.; and when you draw the overlay for where you can move you 
can do a heuristic check for a) they are in the same component, 
and b) the manhattan distances before c) doing a greedy check


Is there a memory allocation technique that would make each 
tile's location in grid inferrable based on it's memory address?


Yes its called an array
theres some details you need to know and you need to cast 
pointers; just try some trial and error with code like:


```d
int[10] foo;

[1].print;
([7]-[0]).print;
```
with whatever casts you need to make it just work


Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-16 Thread monkyyy via Digitalmars-d-learn

On Friday, 15 March 2024 at 20:36:56 UTC, rkompass wrote:


I start to see that D is heavily influenced by C++ (STL), not 
just C.

This is not bad



It is just bad; ranges are not pairs of 2 pointers, stepov was 
comprising with c++ or if he thinks c++ iterators are objectively 
good(not good for making something work with c++) he's lacks taste


even simplified a "random access range" is to complex an 
api(close to 20 functions) when Im pretty sure you need 6 
functions for a coherent array-like interface and when your 
talking about 100 algorthims, well 1400 functions matters


Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-15 Thread monkyyy via Digitalmars-d-learn

On Friday, 15 March 2024 at 09:03:25 UTC, rkompass wrote:

@Monkyyy: I adopted your solution, it is perfect.

I only have one problem left:

The foreach loop with associative arrays has two cases:

`foreach(key, val; arr)` and `foreach(x; arr)`.
In the second case only the values are iterated.
With the present solution the iteration delivers (key, val) 
tuples.


That will not be fixed in d2 ranges and has no good solutions; 
and my affect over d3 seems to be none. You could ask around for 
the "opApply" solution but I dont know it well (and prefer ranges)


d2 Ranges are based on a simplification of stl's ideas and stl 
doesn't support arrays-like iteration well, I wish to change that 
and working on a proof of concept algorthims lib... but well, 
this is unlikely to work.


For d3 if changing the range interface fails, expect to see style 
guides say "prefer explict range starters" string.byUnicode and 
string.byAscii will probably be how they kill `autodecoding` and 
your data stucture having 2 range functions as `byKey` and 
`byKeyValue` will look the same.



Should I do an improvement request somewhere?


I think its been kinda of piecemeal and D1 1D(repetition 
intentional) opSlice is in limbo(it was deprecated, and then 
slightly undepercated in some random chats, its a mess)


for completeness I believe the current state of 1d op overloads 
are:


opIndex(int)
opIndex(key)
opSlice()
opSlice(int, int)
int opDollar()
dollar opDollar()
opSlice(int, dollar)
opBinararyRight("in",K)(key) (opIn was deprecated and shouldn't 
have been)


If your confident in your writing ability id suggest a clean 
slate article based on this list and what the compiler actually 
does(maybe ask around for any I missed) rather than trying to 
untangle this mess


Or write a dip thread "undeperacate d1 opOverloads that are still 
wanted by everyone") and try to bring back opIn at the same time 
and get the limboness of old technically deprecated 1d array 
opOverloads officially gone


Re: varargs when they're not all the same type?

2024-03-14 Thread monkyyy via Digitalmars-d-learn

On Thursday, 14 March 2024 at 17:57:21 UTC, Andy Valencia wrote:
Can somebody give me a starting point for understanding varadic 
functions?  I know that we can declare them


  int[] args...

and pick through whatever the caller provided.  But if the 
caller wants to pass two int's and a _string_?  That 
declaration won't permit it.


I've looked into the formatter, and also the varargs 
implementation.  But it's a bit of a trip through a funhouse 
full of mirrors.  Can somebody describe the basic language 
approach to non-uniform varargs, and then I can take it the 
rest of the way reading the library.


Thanks in advance!
Andy


there are 3 (or 4?) variadic functions
try
```d
auto foo(T...)(T args){
  static foreach(arg;args){
...
```


Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-14 Thread Monkyyy via Digitalmars-d-learn

On Thursday, 14 March 2024 at 16:32:10 UTC, rkompass wrote:

On Thursday, 14 March 2024 at 16:12:00 UTC, rkompass wrote:
Hello @monkyyy again,

your solution is much more elegant:-) No need to do a deep copy.
I was thinking about a way to achieve that but had no clue.

I will study opSlice now.

Your definition of tuple is somewhat obscure to me.
Is this compatible with the Tuple from `std.typecons`?

Greetings,
Raul


Std.tuple is a gaint mess if there's differences in usage syntax 
they are very stupid tradeoffs; fundementally the base languge 
has allot of syntax sugar for "aliasSeq" and my definition of 
tuple is sticking an Seq into a struct; if you look at the code 
for std.tuple it will do the same thing under the name "expand"


If you go down the rabbit hole of learning the template syntax 
you should start with the systax aviable for seq's and 95% of it 
will apply to that definition of tuple


Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-14 Thread monkyyy via Digitalmars-d-learn

On Wednesday, 13 March 2024 at 22:16:52 UTC, rkompass wrote:
I want to make a custom dictionary that I may iterate through 
with foreach. Several times.
What I observe so far is that my dict as a simple forward range 
is exhausted after the first foreach and I have to deeply copy 
it beforehand.

With a simple associative array the exhaustion is not observed.
Is there a (hopefully simple) way to make this 
automatic/transparent? Of course

I need to use the struct.
Can I add a save member function? If yes: How? Or is there an 
operator that is used in the foreach initialization that I may 
overload in this struct?


you need to seperate the range state from the data

```d
import std;
auto tuple(T...)(T t){
struct tuple{
T me; alias me this;
}
return tuple(t);
}
struct mydict(T,S){
T[S] dct;
void opAssign(mydict rhs) {
writeln("--opAssign--");
foreach (k; rhs.dct.keys)  // do a deep copy
dct[k] = rhs.dct[k];
}
auto opSlice(){
struct range{
T[S]* parent;
int i;
auto front()=> 
tuple(parent.keys[i],(*parent)[parent.keys[i]]);

auto popFront()=>i++;
auto empty()=>parent.keys.length<=i;
}
return range();
}
}

void main() {

mydict!(string,string) md, md2;
md.dct = ["h":"no", "d":"ex", "r": "cow"];
md2 = md; // md2.opAssign(md)
foreach (k, v; md[])
writeln("key: ", k, "val: ", v);
writeln("--");
	foreach (k, v; md[])   // does not work with md again, md is 
exhausted

writeln("key: ", k, "val: ", v);
}
```


Re: Error when using `import`.

2024-03-01 Thread monkyyy via Digitalmars-d-learn

On Friday, 1 March 2024 at 05:07:24 UTC, Liam McGillivray wrote:
I don't know how best to organize the code. So far I have been 
oo ideas


for a 2nd opinion: 
https://github.com/crazymonkyyy/raylib-2024/blob/master/docs/examplecode.md


Theres not a good learning resource but "data oirented design": 
pick good data for your problem then do the simplest thing that 
makes it work




Re: length's type.

2024-01-28 Thread monkyyy via Digitalmars-d-learn

On Thursday, 18 January 2024 at 02:55:37 UTC, zjh wrote:
Can you change the type of 'length' from 'ulong' to 'int', so I 
haven't to convert it every time!


The devs are obviously very very wrong here I underflow indexs 
all the time


But this is a pretty dead fight, I'd aim for a smart index type 
thats a "checkedint" with underflow protection and can alias to 
int; cause maybe that could someday happen.


Re: length's type.

2024-01-28 Thread monkyyy via Digitalmars-d-learn

On Sunday, 28 January 2024 at 16:16:34 UTC, Olivier Pisano wrote:

On Sunday, 28 January 2024 at 08:55:54 UTC, zjh wrote:
On Sunday, 28 January 2024 at 06:34:13 UTC, Siarhei Siamashka 
wrote:


The explicit conversion `.length.to!int` has an extra benefit



I rarely use numbers over one million.

But do I have to consider numbers over `4 billion` every day?


If .length were to be an int, D could not handle array of more 
than 2G bytes. The whole language would be useless on 64 bit 
systems.


_Of bytes_ and if your messing with the type and still think 
that's an important concern you could make it a long for 63 bits 
and no silly 0-1 behavior


a signed index of a datatype that is 2 words will still compete 
with the mythical computer ram of a max ram 64 bit machine; if 
you have 64^2 ubytes maybe you should rotate your prospective and 
store 256 counts of each.





Re: Delegates and values captured inside loops

2024-01-20 Thread monkyyy via Digitalmars-d-learn

On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote:
I remember reading this was an issue and now I ran into it 
myself.


```d
import std.stdio;

void main()
{
auto names = [ "foo", "bar", "baz" ];
void delegate()[] dgs;

foreach (name; names)
{
dgs ~= () => writeln(name);
}

foreach (dg; dgs)
{
dg();
}
}
```

Expected output: `foo`, `bar`, `baz`
Actual output:   `baz`, `baz`, `baz`

If I make `names` an `AliasSeq` it works, but I need it to be a 
runtime array.


Is there a workaround?


Everything is sucks, if your throwing out compile time functions 
rewriting it as a struct (or generating a struct) is probaly you 
best bet


```d
struct dg{
  string s;
  void opApply(){
s.writeln;
  }
}
```


Re: The One Billion Row Challenge

2024-01-13 Thread monkyyy via Digitalmars-d-learn

On Thursday, 11 January 2024 at 11:21:39 UTC, Sergey wrote:
On Thursday, 11 January 2024 at 08:57:43 UTC, Christian Köstlin 
wrote:

Did someone already try to do this in dlang?
I guess it will be very hard to beat the java solutions 
running with graalvm!


https://news.ycombinator.com/item?id=38851337

Kind regards,
Christian


I think C++ people already beated Java's performance 
https://github.com/buybackoff/1brc?tab=readme-ov-file#native


I feel we could beat c++ if they didn't radix sort


Re: Less verbose or at least "higher level" 2D game engines for Dlang.

2023-12-29 Thread monkyyy via Digitalmars-d-learn

On Saturday, 30 December 2023 at 00:47:04 UTC, Agent P. wrote:

Hello everyone,

I'm looking for a 2D game engine for Dlang that offers 
flexibility but has a high-level interface, preferably less 
verbose. Although I've explored options on GitHub and in 
general, I haven't found something that exactly fits what I 
need.


Often the recommendations mention SFML, SDL or OpenGL (obvious 
links), but I would like to consider those options only after 
exploring engines with less verbose APIs.


I don't need much, I'm just looking for suggestions for engines 
that meet these criteria. Does anyone have any recommendations?


Thank you for your time.


raylib, take your pick from 5 or so different bindings


Re: surviving wasm

2023-12-13 Thread monkyyy via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 21:15:47 UTC, Julian Fondren 
wrote:


6. statically build against musl and include it in the wasm 
binary. Since phobos is slow to change, its libc dependencies 
will also be slow to change, and you can work on reducing how 
much musl goes into the binary. Musl's MIT-licensed and D has 
ImportC; maybe this can be upstreamed as a pseudo-libc-less 
build option. People who don't care about wasm may still care 
about dodging glibc due to binary portability hassles with 
deployment to older servers. ldc already uses musl on Alpine 
Linux, popular with containers.


I have alpine linux running in distro box and im getting more 
"not my problem" errors
-mtriple=wasm32-unknown-unknown-musl : /stdc/time.d(34): Error: 
undefined identifier `time_t`,
-mtriple=wasm32-linux-musl-webassembly : posix/signal.d(394): 
Error: static assert:  "unimplemented"
--mtriple=i686-linux-musl: /usr/include/d/std/array.d(3418): 
Error: `TypeInfo` cannot be used with -betterC


etc. whats the correct triple even, who knows!

I just can't fix posix signaling or libc.time or clib.math or 
array using typeinfo because I called `float.to!string`


https://github.com/crazymonkyyy/raylib-2024/blob/bf23aede90ea75bfffd074a4bcae04281f21ce27/examples/001-helloworld.d#L11

I have no patience with this direction either, d's std depends on 
libc any claim that "d's std is pay-as-you-go with betterc" is 
delusional, wasm support is half-baked and undocumented Im 
trail-bazing as is.


surviving wasm

2023-12-13 Thread monkyyy via Digitalmars-d-learn
so long term planning on wasm raylib; I want compatibility with 
the good parts of the std, the std is causal about using libc 
while ldc-wasm half-baked implication is missing a bunch of 
basically worthless symbols but given the std is 1 million lines 
of code it will be a perennial problem that I make something work 
natively, I try it in wasm, it breaks citing a random core lib at 
a random line; the options I know about are:


1. use a "team betterc" personal std that doesn't have the apis I 
want, apis I know and probably limited
2. merge "use libc less" upstream to a std that has been slow to 
merge changes and probably doesnt care about wasm

3. fork the std
4. maintain patches to the std that go in and rewrite them live 
with root :D what could go wrong
5. make my own personal std that matches the std api of the parts 
I use


I hate all these options


Patterns for overload set recursion disambiguated by named arguments

2023-12-12 Thread monkyyy via Digitalmars-d-learn

raylib has a collection of well-organized but verbose functions
https://www.raylib.com/cheatsheet/cheatsheet.html

looking at draw
colors are named `color` or if part of a gradient `color1` and 
`color2`
`posx` and `centerx` are a bit more confusing but it should be 
fine

etc.

So I want to make an extremely overload draw function that 
eventually calls some set of these functions, but Im pretty sure 
that "named arguments dont survive T..." is causing problems for 
me, and I'm unsure how to work around it as I make more complex 
versions.


https://github.com/crazymonkyyy/raylib-2024/blob/master/monkyyylib/monkyyydraw.d

(or alternatively please make named arguments survive T...)


Re: Removing an element from a DList

2023-10-17 Thread monkyyy via Digitalmars-d-learn

On Tuesday, 17 October 2023 at 17:27:19 UTC, Joakim G. wrote:
For some reason I cannot remove an element from a DList. I 
tried several range approaches but to no avail. I'm a noob.


In the end I did this:

```
private void removeFromWaitingQueue(uint jid) {
auto arr = waitingQueue[].array;
arr = arr.remove!(job => job.jid == jid);
waitingQueue.clear();
foreach(job; arr) {
waitingQueue.insertBack(job);
}
}
```

Any hints?

/J


"ranges are views of data" blah blah blah that remove function 
returns a fancy pointer and is lazy not the sane eager "unsafe" 
thing, the std avoids mutation to an unhelpful degree also 
std.containeers is awful


Id suggest using dynamic arrays swapping the last element to 
index then length--; or nullable static arrays; or just using 
filter if a functional approach is on the table.


Re: better video rendering in d

2023-03-21 Thread monkyyy via Digitalmars-d-learn

On Tuesday, 21 March 2023 at 17:18:15 UTC, H. S. Teoh wrote:
On Tue, Mar 21, 2023 at 04:57:49PM +, monkyyy via 
Digitalmars-d-learn wrote:
My current method of making videos of using raylib to generate 
screenshots, throwing those screenshots into a folder and 
calling a magic ffmpeg command is ... slow.

[...]

How slow is it now, and how fast do you want it to be?
T


I vaguely remember an hour and half for 5 minutes of video when 
its extremely lightweight and raylib trivially does real-time to 
display it normally and realistically I wouldn't be surprised if 
it could do 1000 frames a second.


Coping several gb of data to disk(that probably asking the gpu 
one pixel at a time) to be compressed down into a dozen mb of 
video is just... temp shit. I should just do something that isnt 
stressing hard drives extremely unnecessarily.




better video rendering in d

2023-03-21 Thread monkyyy via Digitalmars-d-learn
My current method of making videos of using raylib to generate 
screenshots, throwing those screenshots into a folder and calling 
a magic ffmpeg command is ... slow.


Does anyone have a demo or a project that does something smarter 
(or willing to do the busy work of finding the right combo of 
dependencies that just work)


I require basic images, text, and transparent rectangles

https://youtu.be/HxFSmDNvDUI

ideally raylib or image magik for the frame generation


Re: Coding Challenges - Dlang or Generic

2023-01-10 Thread monkyyy via Digitalmars-d-learn
On Tuesday, 10 January 2023 at 19:10:09 UTC, Christian Köstlin 
wrote:

On 10.01.23 01:17, Paul wrote:
There is also https://exercism.org/tracks/d with some tasks for 
dlang.


Kind regards,
Christian


Its all converted code; worthless


Re: Coding Challenges - Dlang or Generic

2023-01-10 Thread monkyyy via Digitalmars-d-learn

On Tuesday, 10 January 2023 at 00:17:18 UTC, Paul wrote:

 I know.  Someone's going to say why don't YOU do it:)


https://github.com/crazymonkyyy/dingbats

I could use contributors


Re: How to use templates in a separate library?

2022-06-23 Thread monkyyy via Digitalmars-d-learn

On Thursday, 23 June 2022 at 08:12:32 UTC, CrazyMan wrote:

linking


make sure you use the -i flag when compiling




Re: nested function overloading

2022-06-22 Thread monkyyy via Digitalmars-d-learn
On Monday, 20 June 2022 at 13:20:51 UTC, Steven Schveighoffer 
wrote:
And you can also use an inner struct to define overloaded 
functions.


I believe templates make a better bandaid
```d
void main(){
template bar(){
void bar_(int){}
void bar_(float){}
alias bar=bar_;
}
bar(1);
bar(3.14);
}
```