Struct value either resets, or not getting passed correctly
https://github.com/ZILtoid1991/pixelperfectengine/blob/ed93bec15deea042516615e73c57d137a2c1f762/pixelperfectengine/src/pixelperfectengine/scripting/lua.d#L98 Struct `LuaVar` seems to work for the most part, however, at certain point, the value seems to be reset to zero, or not being passed to the target function. ```d staticMap!(Unqual,Parameters!Func) params; int stackCounter = 0; try { foreach_reverse(ref param; params) { stackCounter--; param = luaGetFromIndex!(typeof(param))(state, stackCounter); } } ``` My theory is, that if `typeof(param)` is `LuaVar`, I'm missing some extra steps I'm not doing. Other types of data seem to get through, or at least according to me poking around with debuggers.
cannot find source code for runtime library file 'object.d'
``` $ zypper install dmd $ dmd main.d Error: cannot find source code for runtime library file 'object.d' dmd might not be correctly installed. Run 'dmd -man' for installation instructions. config file: /etc/dmd.conf $ cat /etc/dmd.conf ; ; dmd.conf file for dmd ; ; dmd will look for dmd.conf in the following sequence of directories: ; - current working directory ; - directory specified by the HOME environment variable ; - directory dmd resides in ; - /etc directory ; ; Names enclosed by %% are searched for in the existing environment and inserted ; ; The special name %@P% is replaced with the path to this file ; [Environment32] DFLAGS=-I/usr/include/dlang/dmd -L-L/usr/lib -L--export-dynamic -fPIC [Environment64] DFLAGS=-I/usr/include/dlang/dmd -L-L/usr/lib64 -L--export-dynamic -fPIC $ ls /usr/include/dlang/dmd $ cat /etc/os-release NAME="openSUSE Tumbleweed" VERSION="20231006" $ dmd --version DMD64 D Compiler v2.105.3 ``` Help?
Re: D: How do I pipe (|) through three programs using std.process?
On Saturday, 18 November 2023 at 18:09:53 UTC, BoQsc wrote: Latest iteration on this thread. Limitations: * pipes through two programs. * very verbose, hard to use. What exactly are you trying to achieve? ``` import std; import std.process; version (Windows) { enum Find = "find"; } version (Posix) { enum Find = "grep"; } void pipeTo(Pipe p, string nextprogram){ spawnShell(nextprogram, p.readEnd, stdout); ``` If you allow invoking the shell from within your program why don't you use one of its facilities, i.e. the shell's pipe operator `|`, in the first place? `spawnShell` does not execute `nextprogram` but it executes it under the shell. ``` } auto program(string name){ Pipe p = std.process.pipe; spawnShell(name, stdin, p.writeEnd); return p; } void main() { program("echo HelloWorld").pipeTo(nextprogram: Find ~ ` "HelloWorld"`); Have I missed the advent of named function arguments in D? ``` } ``` Your whole program shrinks considerably: ``` import std; import std.process; version (Windows) { enum Find = "find"; } version (Posix) { enum Find = "grep"; } void main() { spawnShell("echo HelloWorld | " ~ Find ~ ` "HelloWorld"`).wait; } ```
Re: How to write an interface but with different signatures
On Sunday, November 19, 2023 1:13:16 AM MST Chris Katko via Digitalmars-d- learn wrote: > I know that sounds stupid on the face of it. An interface > shouldn't change. But consider this: > > A frame timer and a clock timer(seconds) that re-use > functionality from a parent class/interface. > > ``` > class timerType > { > void start() = 0; > void stop() = 0; > void restart() = 0; > void set(?) = 0; // > } > > class frameTimer : timerType > { > void set(int numFrames){} > } > > class clockTimer : timerType > { > void set(float numSeconds){} > } > > ``` > > If we put both signatures in the top we're kind of polluting the > interface. If we don't put them in the interface, then you can > create a timer with no set() function. > > None of this is super important on a practical level. There's > going to probably be a total of two or three timer types. But as > a learning exercise, I'm curious if there is a right/proper/best > way to solve this conceptual problem. > > And to be clear, frames and seconds are NOT directly > interchangeable or convertible. If the game runs at 2 FPS for a > moment, a 5 second timer is still 5 seconds (e.g. a countdown), > but a frame timer of 2 (for an animation) is still going to be 2 > frames. Generally, if a function needs to accept different types depending on the actual type, it doesn't belong on an interface or on a base class, because it cannot be called generically. Rather, you'd normally put the function on the actual class and use it when you're still dealing with the actual object and not the interface. If you need to set the value when it's an interface, then you should probably rethink what you're doing. Obviously, the exact solution which is best is going to depend on your code and the situation, and in some cases, the best solution is to do something like cast the interface to its actual type so that you can call class-specific functions on it, but ideally, once you're dealing with an interface or base class, you just use it as that and don't need to do anything class-specific to it. So, if possible, it's generally better to figure out how to rework your code so that you don't need to set anything that's class-specific in the parts of the code which deal with the object through an interface or base class reference. - Jonathan M Davis
How to write an interface but with different signatures
I know that sounds stupid on the face of it. An interface shouldn't change. But consider this: A frame timer and a clock timer(seconds) that re-use functionality from a parent class/interface. ``` class timerType { void start() = 0; void stop() = 0; void restart() = 0; void set(?) = 0; // } class frameTimer : timerType { void set(int numFrames){} } class clockTimer : timerType { void set(float numSeconds){} } ``` If we put both signatures in the top we're kind of polluting the interface. If we don't put them in the interface, then you can create a timer with no set() function. None of this is super important on a practical level. There's going to probably be a total of two or three timer types. But as a learning exercise, I'm curious if there is a right/proper/best way to solve this conceptual problem. And to be clear, frames and seconds are NOT directly interchangeable or convertible. If the game runs at 2 FPS for a moment, a 5 second timer is still 5 seconds (e.g. a countdown), but a frame timer of 2 (for an animation) is still going to be 2 frames.