On Sunday, 7 February 2021 at 00:05:51 UTC, Tim wrote:
Hi all,
I'm trying to render a diet template out to a WebSocket as a
string to be inserted into a specific portion of the currently
served page. Does anyone know how to go about this?
Is the websocket really needed? Otherwise a plain
Hi all,
I'm trying to render a diet template out to a WebSocket as a
string to be inserted into a specific portion of the currently
served page. Does anyone know how to go about this?
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string, string[]) * a;
a.some_var = hello;
}
}
void main()
{
c = new myclass();
c.MYfunction();
}
This leads to a
Also, (*c).MYfunction() is leading to segmentation fault
sorry, I meant (*a).some_var
not (*c).MYfunction()
On Saturday, 12 July 2014 at 19:16:52 UTC, Danyal Zia wrote:
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
Please consider the following
struct arc(T,U)
{
T some_var;
U someother_var;
}
/* things */
class myclass
{
this(){}
~this(){}
void MYfunction()
{
arc!(string,
On Saturday, 12 July 2014 at 19:19:28 UTC, seany wrote:
For reasons further down in the software, I need to do this
with a pointer. How do I do it with a pointer, please?
I don't know what are you trying to achieve, but if that's what
you want, you can do:
void MYfunction()
{
auto
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those which
are known at a given moment?
On 07/12/2014 12:19 PM, seany wrote:
On Saturday, 12 July 2014 at 19:16:52 UTC, Danyal Zia wrote:
On Saturday, 12 July 2014 at 19:09:44 UTC, seany wrote:
arc!(string, string[]) * a;
a.some_var = hello;
a has not been instantiated. You are declaring it as a pointer to
struct and
On 07/12/2014 12:32 PM, seany wrote:
do I have to initialize all variables of the struct?
No. The uninitialized ones get their .init values.
or may I also use a
this(){} in the struct and initialize only those which are known at a
given moment?
That already works with structs. You don't
On Saturday, 12 July 2014 at 19:32:48 UTC, seany wrote:
do I have to initialize all variables of the struct? or may I
also use a this(){} in the struct and initialize only those
which are known at a given moment?
You can initialize in constructor this(), but you can't
initialize partial
On 07/12/2014 12:38 PM, Danyal Zia wrote:
You can initialize in constructor this(), but you can't initialize
partial fields of struct when using pointer to struct.
Actually, that works too but members must be initialized from the
beginning. The trailing ones are left with .init values:
On Saturday, 12 July 2014 at 19:42:13 UTC, Ali Çehreli wrote:
Actually, that works too but members must be initialized from
the beginning. The trailing ones are left with .init values:
struct S
{
int i;
string s;
}
void main()
{
auto s = new S(42);
static assert(is (typeof(s)
I got to typing one day and came up with this. What it does is
search an aggregate for a member named match. If it's a direct
member, it evaluates to that. If it's not, then it searches any
aggregate type sub-members (deep members) for match. If there's
only one deep member tree with match, it
One way I've used it in code
struct MapBy(T,string key) if (hasDeepMember!(T,key)) {
alias key_t = DeepMemberType!(T,key);
private const(T)[key_t] _map;
bool has(key_t id) const nothrow {
if ((id in _map) != null) return true;
else return
I'm making a template to handle multiple accesses to the same
name. In making my compression algorithm (and BitArray) I realize
how much code is going into just forward referencing to things
based on certain states.
I have the following head template (there's about 5 total with
how I see
On 1/8/13, Era Scarecrow rtcv...@yahoo.com wrote:
template multiAccess(Type, string name, string attributes,
choice, bool read, bool write, T ...) {
I'm calling it with:
int choice;
writeln(multiAccess!(int, test, @safe nothrow pure, choice,
true, true,
'choice' is not
On Tuesday, 8 January 2013 at 19:58:20 UTC, Era Scarecrow wrote:
I'm making a template to handle multiple accesses to the same
name. In making my compression algorithm (and BitArray) I
realize how much code is going into just forward referencing to
things based on certain states.
I have
On Tuesday, 8 January 2013 at 20:07:29 UTC, monarch_dodra wrote:
You appear to want choice to represent a value, rather than a
type.
Declare it as int choice or alias choice
Not that with int choice, you'll get a compiler error because
it isn't a compile constant. I'm not really sure about
On Tue, Jan 8, 2013 at 9:14 PM, Era Scarecrow rtcv...@yahoo.com wrote:
On Tuesday, 8 January 2013 at 20:07:29 UTC, monarch_dodra wrote:
You appear to want choice to represent a value, rather than a type.
Declare it as int choice or alias choice
Not that with int choice, you'll get a
Well after getting the alias problem out of the way, I have a
working template. If anyone cares to look it over and critique
it. I'll consider adding it to phobos (assuming I didn't miss
something similiar), although I am not sure where it would be
added as it doesn't quite qualify for
On Tue, Jan 8, 2013 at 10:37 PM, Era Scarecrow rtcv...@yahoo.com wrote:
Well after getting the alias problem out of the way, I have a working
template. If anyone cares to look it over and critique it. I'll consider
adding it to phobos (assuming I didn't miss something similiar), although I
Philippe Sigaud:
alias for templates gives you a 'symbol' parameter: you can
pass any
identifier to it: variable, user-defined types, module names...
Not built-in types (int,...) which are keywords and *not* valid
identifiers.
I remember some persons have asked for built-in types too to
On Tuesday, 8 January 2013 at 23:17:46 UTC, Philippe Sigaud wrote:
On Tue, Jan 8, 2013 at 10:37 PM, Era Scarecrow wrote:
Some comments:
mixin(multiAccess!(
int,//return type
test, //function call/name
nothrow, //attributes
On Tuesday, 8 January 2013 at 23:17:46 UTC, Philippe Sigaud wrote:
The 'int,' part is not necessary: names a and b have a type,
you can determine int from CommonType!(typeof(a),typeof(b)).
One less field for your user.
Here's a working example, although my updated code hasn't been
synced
Updated code, now accepts quoted strings for choice variables.
https://github.com/rtcvb32/Side-Projects/blob/master/multiaccess.d
I'm writing some manual reflection (a bit more automatism will come later,
thanks to __traits and mixin)(hopefully)
There are a few problems with my implementation so far...
- First the implementation:
system.reflection.member.d =
module system.reflection.member;
public:
public enum
27 matches
Mail list logo