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

2024-03-18 Thread novice2 via Digitalmars-d-learn

On Monday, 18 March 2024 at 10:05:43 UTC, novice2 wrote:

On Monday, 18 March 2024 at 08:50:42 UTC, rkompass wrote:
Or are the types T and S are put on the stack like ordinary 
arguments and the usage of arg1 and arg2 within the function 
is enveloped in switches that query these Types?


IMHO, only if you instantiate (make call) templfunc, then 
compiler create function with specified types.

Function created only once for given types combination.


this also can be helpfull:
https://dlang.org/spec/template.html#common_instantiation


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

2024-03-18 Thread novice2 via Digitalmars-d-learn

On Monday, 18 March 2024 at 08:50:42 UTC, rkompass wrote:
Given the types S and T in say `templfunc(S, T)(S arg1, T arg2) 
{}`
represent 2 different actual types in the program, does that 
mean that there are 4 versions of the `templfunc` function 
compiled in? (This was the C++ way iirc).


IMHO, only if you instantiate (make call) templfunc with all 
types.



Or are the types T and S are put on the stack like ordinary 
arguments and the usage of arg1 and arg2 within the function is 
enveloped in switches that query these Types?


IMHO, only if you instantiate (make call) templfunc, then 
compiler create function with specified types.

Function created only once for given types combination.


Re: Operator "+=" overloading for class?

2023-12-17 Thread novice2 via Digitalmars-d-learn

On Monday, 18 December 2023 at 03:39:16 UTC, Ki Rill wrote:
On Sunday, 17 December 2023 at 07:05:12 UTC, Adam D. Ruppe 
wrote:

On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote:

[...]


check what `op` is. pretty sure it is "+" not "+=" so your 
element isnt' saved anywhere. also a bit iffy there isn't a 
member here to work on


Yes, op is '+'. What do you mean by it isn't saved anywhere?


your code just return result value,
but it should not return but save result to "this"
see example at 
https://dlang.org/spec/operatoroverloading.html#index_op_assignment





Re: How can I get the total memory size of a Jagged Array

2023-11-14 Thread novice2 via Digitalmars-d-learn

may be std.string.representation() may help?
https://dlang.org/phobos/std_string.html#.representation

byteSize = representation(myString).length;


Re: DMD: How to compile executable without producing .obj file?

2023-11-12 Thread novice2 via Digitalmars-d-learn
on windpows you can hide (move .obj away from sources dir) by add 
to compile command

-od="%TEMP%\dmd\myproject"


Re: isBinary

2023-09-12 Thread novice2 via Digitalmars-d-learn

On Sunday, 3 September 2023 at 13:55:45 UTC, Vino wrote:

f.open(fn, "rb");


here you command to your pc: "now open fn and treat is as binary 
file"




Re: Counting an initialised array, and segments

2023-06-25 Thread novice2 via Digitalmars-d-learn

```
import std;
auto arr = [dchar(' '), '\t', 0x0a, 0x10];
void main()
{
writeln("Hello D: ", typeid(arr));
}
```


Re: GetInterfaceInfo function of win32 api

2023-06-07 Thread novice2 via Digitalmars-d-learn

On Thursday, 8 June 2023 at 05:29:07 UTC, Benny wrote:

Hello,


Hi!


I'm trying to call the function GetInterfaceInfo


it would be nice to see the code


didn't work.


it would be nice to see specifics (error code, results, etc)


Re: How static link dll msvcr120.dll?

2023-06-01 Thread novice2 via Digitalmars-d-learn

On Thursday, 1 June 2023 at 15:05:40 UTC, Marcone wrote:
I linked msvcr120.lib, but the executable still ask for 
msvcr120.dll not found.



i am sorry.
my words was sourced from common sence, usual practice.
it seems, msvcr120 is special case, and have only one version of 
.lib - for link to .dll

i cant find static lib for msvcr120 :(


Re: How static link dll msvcr120.dll?

2023-05-29 Thread novice2 via Digitalmars-d-learn

you cannot "static link dll", "d" in "dll" is "dynamic".
you can implicity or explicity load dll.

https://learn.microsoft.com/en-us/cpp/build/linking-an-executable-to-a-dll?view=msvc-170

may be you mean static link msvcr120.lib?
i am not windows guru, but you need msvcr120.lib (there is 2 
version of .lib - one small for use .dll and contain only 
reference to code in dll, other large, for static linking, 
contains all code).


to link mylib.lib you can use pragma(lib, "mylib.lib") in D code.



Re: Convert binary to UUID from LDAP

2023-03-27 Thread novice2 via Digitalmars-d-learn

On Monday, 27 March 2023 at 17:56:22 UTC, Alexander Zhirov wrote:
I get `objectGUID` data from LDAP as binary data. I need to 
convert `ubyte[]` data into a readable `UUID`. As far as I 
understand, it is possible to do this via `toHexString()`, but 
I have reached a dead end. Is there a way to make it more 
elegant, like [this 
technique](https://dlang.org/phobos/std_uuid.html#.UUID)?


```
ubyte[] => [159, 199, 22, 163, 13, 74, 145, 73, 158, 112, 7, 
192, 12, 193, 7, 194]

hex => 9FC716A30D4A91499E7007C00CC107C2
```


https://run.dlang.io/is/JP01aZ

```
void main(){
import std.stdio: writeln;
import std.format: format;
ubyte[] a = [159, 199, 22, 163, 13, 74, 145, 73, 158, 
112, 7, 192, 12, 193, 7, 194];

string b = format("%(%.2X%)",a);
writeln(b);
}
```


Re: compile x64 .dll and .so without dependencies

2023-03-05 Thread novice2 via Digitalmars-d-learn

On Sunday, 5 March 2023 at 18:35:58 UTC, Guillaume Piolat wrote:

"targetType": "dynamicLibrary",
"dflags-linux-dmd": ["-defaultlib=libphobos2.a"],
"dflags-osx-ldc": ["-static"],
"dflags-linux-ldc": ["-link-defaultlib-shared=false"],
"dflags-linux-x86_64-ldc": ["-fvisibility=hidden"],
"dflags-windows-ldc": 
["-mscrtlib=libcmt","-fvisibility=hidden", 
"-link-defaultlib-shared=false"],


Additionally on (Windows + DUB + LDC), you will need to set an 
envvar:

DFLAGS=-fvisibility=hidden -dllimport=none


Thank you!


compile x64 .dll and .so without dependencies

2023-03-04 Thread novice2 via Digitalmars-d-learn

It there any recipe to compile x64 .dll without dependencies?

I mean it shoud be used without installing things like 
msvcr120.dll.

Dependencies on system dll (advapi32.dll, kerner32.dll) is ok.

I don't experiment on linux yet. But interest too.


Re: Why does the importC example not compile?

2023-01-13 Thread novice2 via Digitalmars-d-learn

try to rename function to distinguish from source module


Re: dChar Error

2022-12-30 Thread novice2 via Digitalmars-d-learn

On Friday, 30 December 2022 at 04:43:48 UTC, Salih Dincer wrote:

  ...
  // example one:
  char[] str1 = "cur:€_".dup;
  ...
  // example two:
  dchar[] str2 = cast(dchar[])"cur:€_"d;
  ...
SDB@79


why you use .dup it example one, but not use in example two?

dchar[] str2 = cast(dchar[])"cur:€_"d.dup;


Re: [Win32 API] MessageBox Example without MSVCR120.dll dependency

2022-12-25 Thread novice2 via Digitalmars-d-learn

to avoid special compile command just add one code line:

pragma(lib, "user32.lib");



Re: Passing a string by reference

2022-11-08 Thread novice2 via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 12:30:50 UTC, Alexander Zhirov 
wrote:

A c;


this declaration not creates class instance. you should use "new".

btw, struct have other behavoiur



Re: A look inside "filter" function defintion

2022-08-03 Thread novice2 via Digitalmars-d-learn

leyts try very rough simlified concept:

template itself - is compile-time program (parameterizable), it 
can generate some code for you.


template instantiation (like "calling") with "!" - instruct 
compiler to "start this compile-time program here with this 
parameters".





Re: Using regular expressions when reading a file

2022-05-06 Thread novice2 via Digitalmars-d-learn

imho, regexp is overkill here.
as for me, i usually just split line for first '=', then trim 
spaces left and right parts.


Re: How to update Associative Array?

2022-02-10 Thread novice2 via Digitalmars-d-learn
On Thursday, 10 February 2022 at 12:08:07 UTC, tastyminerals 
wrote:
I meant a different thing though. I am looking for 
`mydic.update(another_dic)` analogue where `{"a": 1, "b": 2}` 
update `{"c": 3, "a": -1}` becomes `{"a":-1, "b": 2, "c": 3}`.


you need "merge"?
https://forum.dlang.org/post/fhhuupczjnhehxplj...@forum.dlang.org



Re: Analyze debug condition in template

2021-10-27 Thread novice2 via Digitalmars-d-learn

On Wednesday, 27 October 2021 at 08:14:29 UTC, Kagamin wrote:
...
Then the logger can inspect symbols in the template argument 
and compare their names to the function name.



Aha, thank you, i will try!


Re: Analyze debug condition in template

2021-10-26 Thread novice2 via Digitalmars-d-learn
On Tuesday, 26 October 2021 at 15:53:54 UTC, Steven Schveighoffer 
wrote:

mixin("debug(" ~ func ~ ") doRealThing();");


Thank you, Steven.

Unfortunately, all variants with global "-debug" in command line 
is unhandy.

It leads to ugly, very big command line :(

Note that setting debug versions doesn't get seen in imported 
modules, only ones specified on the command line will be seen 
inside your logger.


This is the problem.

At the moment i failed to get "debug" condition from one module 
(caller) in other module (logger).
Variant with UDA failed too - i can't get UDA from one module 
(caller) in other module (logger).


Re: Analyze debug condition in template

2021-10-26 Thread novice2 via Digitalmars-d-learn

On Tuesday, 26 October 2021 at 09:44:42 UTC, Kagamin wrote:

`debug(func1)writefln(...)`
But specify a global debug version for the compiler:
`dmd -debug=func1 app.d`


i want to eliminate "debug(func1)"
i want to be able on/off debugging for one function or another,
and logf() template should "understand", those on/off for caller


Re: Analyze debug condition in template

2021-10-26 Thread novice2 via Digitalmars-d-learn

Thanks Kagamin!

One more way, i think,
mark function with UDA,
and then analize UDA in template.
But i have problem to implement this:

i have function name __FUNCTION__ in template as sting,
but __traits(getAttributes, __FUNCTION__) want symbol,
not string as second parameter :(


Re: Error when compile with DMD using -m64?

2021-08-09 Thread novice2 via Digitalmars-d-learn

On Monday, 9 August 2021 at 19:53:48 UTC, Marcone wrote:

program not run.


compilation errors?
runtime errors?


writef, compile-checked format, pointer

2021-08-09 Thread novice2 via Digitalmars-d-learn

format!"fmt"() and writef!"fmt"() templates
with compile-time checked format string
not accept %X for pointers,

but format() and writef() accept it

https://run.dlang.io/is/aQ05Ux
```
void main() {
import std.stdio: writefln;
int x;
writefln("%X", );  //ok
writefln!"%s"();  //ok
//writefln!"%X"();  //compile error
}
```

is this intentional?


Re: Creating std.format.format warpper

2021-05-01 Thread novice2 via Digitalmars-d-learn

On Saturday, 1 May 2021 at 16:21:33 UTC, Anonymouse wrote:

https://run.dlang.io/is/QsYCkq
http://ddili.org/ders/d.en/templates.html).


thanks for your time!


Creating std.format.format warpper

2021-05-01 Thread novice2 via Digitalmars-d-learn

Hello.

Can please anybody help me create template format2 like 
std.format.format,

so it can access to format string (change it for example)
then instantiate std.format.format template in 
compile-time-checkable way

format!"%d %s"(arg1, arg2)
so compiler can check format string vs arguments count at least.

i.e. if i would write
format2!"%d %s"(arg1)
i should give comile time error

and next difficulties, i want format2 have extra parameter (say 
"prefix"), not passed to std.format.format


for example, format2 should prepent prefix to format string then 
instantiate std.format.format


any advices
thanks


Re: nothrow and std.exception.ifThrown

2021-05-01 Thread novice2 via Digitalmars-d-learn

btw for my immediate needs i replace second delegate with value
i.e. remove "lazy" from declaration and remove "()" in return

so ifThrown loose some generity

```d
nothrow
CommonType!(T1, T2) ifThrown(E : Throwable = Exception, T1, T2)
(lazy scope T1 expression, scope T2 
expression2)

...
try
return expression();
catch (E)
return expression2;
```



Re: nothrow and std.exception.ifThrown

2021-04-29 Thread novice2 via Digitalmars-d-learn

Thank you Imperatron, Ali
both variants
```d
  scope(failure) assert(0);
```
```d
  collectException
```
works!

Thank Meta
The reason for this, apparently, is in the definition of 
`ifThrown`


i tried to modify ifThrown adding nothrow,
but compiler dont understand, that second parameter cant throw,
it just expression.

i dont understand why (templates too dificult for me yet),
but if i comment "lazy" from T2,
then compiler allow add "nothrow" to "ifThrown"

```d
CommonType!(T1, T2) ifThrown(E : Throwable = Exception, T1, 
T2)(lazy scope T1 expression, /*lazy*/ scope T2 errorHandler) 
nothrow

```
https://run.dlang.io/is/KTdd3G


nothrow and std.exception.ifThrown

2021-04-29 Thread novice2 via Digitalmars-d-learn

Hello.
I need use std.format.format() in nothrow function.
format() can throw.
For this case i have special default string.
I don't want embrace format into try..catch block,
and i found elegant std.exception.ifThrown.
But DMD say "ifThrown not nothrow"

https://run.dlang.io/is/kXtt5q
```d
nothrow string foo(int x, string def) {
import std.format: format;
import std.exception: ifThrown;

return format("%d", x).ifThrown(def);
}

Error: function std.exception.ifThrown!(Exception, string, 
string).ifThrown is not nothrow

```

What i can use instead of ifThrown, or how it can be changed to 
nothrow?

Thanks.


Re: Is this bug ? format %(%)

2021-04-07 Thread novice2 via Digitalmars-d-learn

On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote:

So, you should change your code to

writefln("%-(%s, %)", s);


sorry i dont read docs so carefully
thanks


Re: Derived type

2021-04-01 Thread novice2 via Digitalmars-d-learn

thanks, i tried 2 variants:
```d
struct Tnew {TBase payload; alias payload this;}
```
```d
enum Tnew : Tbase {init = Tbase.init}
```

both works, but 1-st not allow "2 level" cast:
```d
struct Xptr {void* payload; alias payload this;} //Xptr based on 
void*
struct Xobj {Xptr payload; alias payload this;}  //Xobj based on  
Xptr

Xptr xptr = cast(Xptr) null; //OK
Xobj xobj = cast(Xobj) null; //ERROR
Xobj xobj = cast(Xobj) cast(Xptr) null;  //OK, needs both levels 
explitity

```
```d
enum Xptr : void* {init = (void*).init} //Xptr based on void*
enum Xobj : Xptr {init = Xptr.init} //Xobj based on  Xptr
Xptr xptr = cast(Xptr) null;//OK
Xobj xobj = cast(Xobj) null;//OK
```

so "enum" variant is better for me, thanks!


Re: Derived type

2021-03-30 Thread novice2 via Digitalmars-d-learn

My tries to make template for struct and alias this:

// variant 1
template Typedef(alias Tnew, Tbase)
{
  struct Tnew
  {
Tbase payload;
alias payload this;
  }
}

Typedef!(Xobj, void*);

void foo (Xobj obj) {}  //compiler Error: no identifier for 
declarator Typedef!(Xobj, void*)



// variant 2
mixin template Typedef(alias Tnew, Tbase)
{
  struct Tnew
  {
Tbase payload;
alias payload this;
  }
}

mixin Typedef!(Xobj, void*);  //compiler Error: undefined 
identifier Xobj





Re: Derived type

2021-03-30 Thread novice2 via Digitalmars-d-learn

On Tuesday, 30 March 2021 at 19:12:29 UTC, Ali Çehreli wrote:
"Derived type" is used in the context of object oriented 
programming at least in D


Sorry, i use wrong termin.
I just want create new type Tnew, based on exist type Tbase.
Tnew have same allowed values, same properties, same allowed 
operations as Tbase.

Compiler should distinguish New from Tbase.
Allowed implicit cast Tnew to Tbase.
Prohibited implicit cast Tbase to Tnew.
Allowed exlicit cast Tbase to Tnew.


but your examples indicate you need something else. How about 
the 'alias this' feature?


Thanks, this is what i want.
I just think that Typedef do it for me, hide this boilerplait 
code.




Re: Derived type

2021-03-30 Thread novice2 via Digitalmars-d-learn

On Tuesday, 30 March 2021 at 14:45:12 UTC, WebFreak001 wrote:
Xobj can then be used interchangeably with void*, so all void* 
arguments accept Xobj and all Xobj arguments accept void*.


yes, i understand alias, and i dont want such behaviour


If you want a type-safe alias that makes all void* arguments 
accept Xobj but not Xobj arguments to accept void*


yes, this is that i search



you can use `Typedef` like you linked.


Problem with Typedef template - code
  alias Xobj = Typedef!(void*)
not generate type named "Xobj",
but type named "Typedef!(void*, null, null)".
This makes compiler error messages unusable.



enum Xobj : void*;
```
This allows explicit conversion in both ways using cast, but 
only allows implicit conversion from Xobj to void*, not from 
void* to Xobj:


Strange syntax.
Behavour exactly what i want, but this code not works for me :(

  enum Xobj : void*;
  Xobj var;  //DMD Error: enum test7.Xobj forward reference of 
Xobj.init




Re: Derived type

2021-03-30 Thread novice2 via Digitalmars-d-learn

On Tuesday, 30 March 2021 at 13:43:52 UTC, Mike Parker wrote:

the straightforward way is just to use an alias.


i cant use alias - compiler cannot distinguish base type and 
alias, and cannot catch programmer errors


Buf if you need a more concrete type, you can use alias this in 
a struct:

I think Typedef template should do this struct for me.

Thanks Mike, this way is what i wanted

  struct Xobj {
private void* payload;
alias payload this;
  }

  Xobj good;
  foo(good);//nice
  foo(cast(Xobj)null);  //explicit cast allowed - nice
  foo(null);//no implicit cast disallowed - compiler 
error - nice


  void* bad;
  foo(bad); //compiler distinguish type - error - nice


I think Typedef template should do this struct for me.

Problem with Typedef template - code
  alias Xobj = Typedef!(void*)
not generate struct named "Xobj",
but struct named "Typedef!(void*, null, null)".
This makes compiler error messages unusable.

I will try to make template for struct. But template is black 
magic for me :)


Re: Since DMD 2.089.0 and later, compiled .exe showing SFX zip and opening with winRar when use resource.

2020-08-30 Thread novice2 via Digitalmars-d-learn

5. Open WinRAR support issue
6. Upload your .exe and say WinRar version then other peoples can 
reproduce


Re: Since DMD 2.089.0 and later, compiled .exe showing SFX zip and opening with winRar when use resource.

2020-08-30 Thread novice2 via Digitalmars-d-learn

Dear Marcone, that you want we all to do?
Rar detect sfx by small signature, and some bytes in exe looks 
like signature.

But this is not the problem - just do not open your exe with rar.
Or i just don't understand...

Another options:
1. try to compile with anoter .res or/and  another .ico (if magic 
bytes in .res)

2. wait next dmd version (if magic bytes in dmd runtime)
3. try gdc or ldc from https://dlang.org/download.html (if magic 
bytes in dmd runtime)

4 try to pack yor exe with free packer like https://upx.github.io/


Re: RtlAdjustPrivilege and NtRaiseHardError

2020-05-24 Thread novice2 via Digitalmars-d-learn
"doesn't work" isn't very helpful. Are you seeing compiler 
errors? Linker errors? Runtime errors? Please describe your 
problem.


Solved my problem alone : wrong signatures with functions ;)


and this reply isn't very helpful.
what is right signature?
you go to forum to ask help.
but wish you help to other readers, those will have the ame 
problems?


Re: Working with cmd

2020-04-18 Thread novice2 via Digitalmars-d-learn

On Friday, 17 April 2020 at 21:38:23 UTC, Quantium wrote:

Are there any libs which can be used to access cmd commands?


std.process

https://dlang.org/phobos/std_process.html#.execute



Re: How to converte string to wstring[]?

2020-02-06 Thread novice2 via Digitalmars-d-learn

import std.conv: to;

string str = "test1";
wstring[] wstr = [to!wstring(str)];


Re: What is wrong with this function that I can not get resource content?

2020-02-05 Thread novice2 via Digitalmars-d-learn

On Wednesday, 5 February 2020 at 20:01:19 UTC, Marcone wrote:

Sorry! Solved. Just need add # in this line:

get_resource("#300", "BMP", "melancia.bmp");


the mistake, very imho, is not check windows API functions 
results.

you can use wenforce:
https://dlang.org/phobos/std_windows_syserror.html#.wenforce


Re: foreach loop

2015-10-19 Thread novice2 via Digitalmars-d-learn

On Monday, 19 October 2015 at 15:56:00 UTC, Namal wrote:

Is it possible to use foreach backwards?



yes
http://dlang.org/statement.html#ForeachStatement
http://dpaste.dzfl.pl/cf847a9e1595


Re: Why does File.byLine() return char[] and not string

2015-10-18 Thread novice2 via Digitalmars-d-learn

what buffer you are talking.


internal buffer. where result line resides.



And what is "signal"? How it's working?


just the fact for programmer, that result line can be changed by 
other code (by phobos library code in this case).


no any special programming "signal".



Re: dis...@dlang.org

2015-09-23 Thread novice2 via Digitalmars-d-learn

http://forum.dlang.org/thread/hrzfcjrltftgzansd...@forum.dlang.org
https://github.com/Trass3r/hooksample


Re: Regex-Fu

2015-05-25 Thread novice2 via Digitalmars-d-learn

I cannot get the longest possible

it match longest for first group ([a-z]+)

try

^([a-z]+?)(hula|ula)$



Re: getopt helpWanted

2015-04-30 Thread novice2 via Digitalmars-d-learn

Thank you, Brian!


getopt helpWanted

2015-04-29 Thread novice2 via Digitalmars-d-learn

Hello.

Help me please to understand, how to show usage help to user, who 
enter wrong options?

For example, user not provided required filename.
I want to show error message, and program usage help text.
But likely getopt don't provide help text until valid options 
will be parsed.


Reduced code:
///
import std.stdio: writefln;
import std.getopt;

void main (string[] args)
{
  string fname;
  GetoptResult helpInfo;

  try
  {
helpInfo = getopt(
  args,
  std.getopt.config.required, file|f, File name, fname);

writefln(Options parsed: fname=%s, fname);
  }
  catch(Exception e)
  {
writefln(\nERROR: %s, e.msg);
defaultGetoptPrinter(Program usage:, helpInfo.options);
  }
}
///

Output:
ERROR: Required option file|fwas not supplied
Program usage:


Re: Benchmark of D against other languages

2015-04-01 Thread novice2 via Digitalmars-d

I am sorry for so dumb question, but:
when peoples talking about D and speed,
then they always say mark method final.
Can DMD compiler do it itself, as one of optimizations?


Re: ErrnoException in Windows

2015-03-01 Thread novice2 via Digitalmars-d-learn

Thans guys!

wenforce not sutable - error code is lost.
may be, i will use modified wenforce, wich throws ErrnoException.


Re: ErrnoException in Windows

2015-03-01 Thread novice2 via Digitalmars-d-learn

Ha, i found
std.windows.syserror: WindowsException, wenforce;


ErrnoException in Windows

2015-03-01 Thread novice2 via Digitalmars-d-learn

Could you, please, help me to understand, why code:


import std.c.windows.windows;
import std.exception: ErrnoException;
import std.stdio: writefln;
import std.string: toStringz;

void main ()
{
  CreateFileA(toStringz(nonexisting file name), GENERIC_READ, 
FILE_SHARE_READ, null, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 
null);

  auto ex = new ErrnoException(CreateFileA);
  writefln(ex.errno=%d, ex.msg=%s, lasterror=%d, ex.errno, 
ex.msg, GetLastError());

}


prints:
ex.errno=0, ex.msg=CreateFileA (No error), lasterror=2

I wanted it will be:
ex.errno=2, ex.msg=CreateFileA (File not found), lasterror=2


one problem at dlang.org site

2015-02-23 Thread novice2 via Digitalmars-d-learn

sorry - i cant find where i can post this.
bugtracker have no dlang.org product.

when i click to left menu Standart Library - std - windows - 
charset
then i have error The requested URL 
/phobos/std_windows_charset.html was not found on this server.


Re: string concatenation with %s

2015-01-07 Thread novice2 via Digitalmars-d-learn

what if a_college[i] will contain ` char?
almost SQL have prepare statement...


Re: Scoped external function declaration

2015-01-02 Thread novice2 via Digitalmars-d-learn

Thanx Daniel, thanx Ketmar.

I just thinked that this is some sort of bug.
May be DMD should not change mangled name of external function...
Bit i dont know.


Re: forum.dlang.org is now using DCaptcha

2014-12-02 Thread novice2 via Digitalmars-d-announce
On Wednesday, 3 December 2014 at 07:29:25 UTC, Jacob Carlborg 
wrote:
The anonymous class feature question, I was a bit stunned at 
first, before I saw what it actually was.


i can't pass it too - only looking to sources.
i tried auto type deduction, type deduction etc...
imho, name of feature - bad question choice.


Re: convert static arrays to dynamic arrays and return, have wrong data.

2014-11-09 Thread novice2 via Digitalmars-d

BTW, adding .dup resolve error:

int[] test11()
{
  return test1().dup;
}

int[] test22()
{
  return test2().dup;
}


Re: convert static arrays to dynamic arrays and return, have wrong data.

2014-11-09 Thread novice2 via Digitalmars-d

int[3] test1()
{
  int[3] arr;
  ...
}

disasm shows:
- arr created on stack
- arr address returned
- stack changed
- data lost.



Re: Templates for structures

2014-11-04 Thread novice2 via Digitalmars-d-learn

On Monday, 3 November 2014 at 14:53:29 UTC, Ali Çehreli wrote:
It sounds possible but I don't understand it yet. Can you give 
an example of the input and output to the D code?


Ali


Thank you Ali.
I realized, that my wishes look like serialization.
So i decide read and learn code from existent serialization 
libraries.


Templates for structures

2014-11-02 Thread novice2 via Digitalmars-d-learn

Hello.

I need write some wrapper around legacy data structure.
May be it should be class. May be structure with methods.
The problem is writing repetitive code for underlying data.
For example:
 - code to read length-byte-prefixed string to D string for every 
field in every structure;

 - code to write D string back to length-byte-prefixed string;

Is it possible to write some template or mixin, and then just 
write

myStruct.addFiled(type=ByteLengthString, name=name)
myStruct.addFiled(type=ShortLengthString, name=filed2)
myStruct.addFiled(type=WeirdStoredInteger, name=counter)

May be it can be done with template, mixin, UDA, ...?

May be something already realized, and i can see sources as 
example?


Any ideas or examples please.
Just show direction for me )

Thanx.


Is this RDMD bug ?

2014-08-23 Thread novice2 via Digitalmars-d-learn
I have 2 reduced files, wich i can't compile with new (DMD 2.066) 
rdmd.exe under Windows 7 32-bit.


Command: rdmd --force --build-only aaa.d
Message Error 42: Symbol Undefined _D3etc3bbb3fooFZi

But command: dmd aaa.d etc\bbb.d
Compile without errors.
And then i replace rdmd.exe by old (from DMD 2.065) compile OK 
too.


Can anybody reproduce this?


/*** begin of file aaa.d ***/
import etc.bbb;

void main()
{
  int i = foo();
}
/***/


/*** begin of file etc\bbb.d ***/
module etc.bbb;

public int foo()
{
  return 1;
}
/***/


Re: Is this RDMD bug ?

2014-08-23 Thread novice2 via Digitalmars-d-learn
On Saturday, 23 August 2014 at 17:32:15 UTC, Vladimir Panteleev 
wrote:

etc is a standard D package name reserved for Phobos, the


Thanks for explanation.
I not be able to undertsand the cause - weird error message.
Now i can easy fix my code.

BTW, did rdmd determine user code or standard library by sorce 
file pathes?

Or it those names must be hardcoded?


Re: D 2.066 is out. Enjoy!

2014-08-19 Thread novice2 via Digitalmars-d-announce

http://dlang.org/changelog.html
Version D 2.066 August 18, 2014
...
Phobos enhancements
 1.Bugzilla 3780: getopt improvements by Igor Lesik


Sorry, i can't find this improvements nor in getopt.d nor in 
http://dlang.org/phobos/std_getopt.html.


Is this announce prematurely, and that this changes will be seen 
in 2.067 ?


Re: Struct's alignment

2013-08-10 Thread novice2

i guess, because of allocated on stack:

import std.stdio;

align(16) struct S
{
  align(16) int a;
}

S sGlobal;

void main()
{
  S sLocal;
  writefln(0x%08X 0x%08X, cast(uint) sGlobal, cast(uint) 
sLocal);

}

0x00162110 0x0012FE14

but, IMHO, this is not good


Re: std.bigint: BigInt conversion

2012-12-03 Thread novice2
Big thank you. I hope, this changes will be included in phobos in 
future.


std.bigint: BigInt conversion

2012-11-25 Thread novice2

How i can convert ubyte[] to BigInt and BigInt to ubyte[] ?
Or uint[]...

For example, i need RSA crypto. I should get ubyte[] data, 
ubyte[] key, convert it to BigInt, calculate, then save result as 
ubyte[] data again.


But i see BigInt convertable to string only :(


Re: Struct members align in DMD 2.060

2012-10-07 Thread novice2

Thanx Maxim,
but what about

S2.sizeof (should be 6) = 8

S3.sizeof (should be 6) = 8


Re: Struct members align in DMD 2.060

2012-10-07 Thread novice2

Thanx again.
Code align(1) struct ... { align(1): ... }
rescue me and return pre 2.060 behaviour


Re: Struct members align in DMD 2.060

2012-10-07 Thread novice2

and contain additional 2 trailing bytes


But, imho, this is unproperly to include something outside 
struct in its size.




Struct members align in DMD 2.060

2012-10-06 Thread novice2

Some of my code broken in DMD 2.060.
I need packed struct without align to process data.
Is this bug or something changed in 2.060 ?
Code http://dpaste.dzfl.pl/212ca53b :

import std.stdio;

align(1) struct S1
{
  char[2]  c;  //+0
  uint u;  //+2
}

struct S2
{
  align(1):
  char[2]  c;  //+0
  uint u;  //+2
}

struct S3
{
  align(1) char[2]  c;  //+0
  align(1) uint u;  //+2
}

void main()
{
  writeln( compiler ,__VENDOR__,  , __VERSION__);
  writeln;

  writeln(S1.c.offsetof (should be 0) = , S1.c.offsetof);
  writeln(S1.u.offsetof (should be 2) = , S1.u.offsetof);
  writeln(S1.sizeof (should be 6) = , S1.sizeof);
  writeln;

  writeln(S2.c.offsetof (should be 0) = , S2.c.offsetof);
  writeln(S2.u.offsetof (should be 2) = , S2.u.offsetof);
  writeln(S2.sizeof (should be 6) = , S2.sizeof);
  writeln;

  writeln(S3.c.offsetof (should be 0) = , S3.c.offsetof);
  writeln(S3.u.offsetof (should be 2) = , S3.u.offsetof);
  writeln(S3.sizeof (should be 6) = , S3.sizeof);
  writeln;
}


Output:

 compiler Digital Mars D 2059

S1.c.offsetof (should be 0) = 0
S1.u.offsetof (should be 2) = 2
S1.sizeof (should be 6) = 6

S2.c.offsetof (should be 0) = 0
S2.u.offsetof (should be 2) = 2
S2.sizeof (should be 6) = 6

S3.c.offsetof (should be 0) = 0
S3.u.offsetof (should be 2) = 2
S3.sizeof (should be 6) = 6


 compiler Digital Mars D 2060

S1.c.offsetof (should be 0) = 0
S1.u.offsetof (should be 2) = 4
S1.sizeof (should be 6) = 8

S2.c.offsetof (should be 0) = 0
S2.u.offsetof (should be 2) = 2
S2.sizeof (should be 6) = 8

S3.c.offsetof (should be 0) = 0
S3.u.offsetof (should be 2) = 2
S3.sizeof (should be 6) = 8



Re: Struct members align in DMD 2.060

2012-10-06 Thread novice2
btw GDC and LDC 2.060 produces same output as DMD 2.060 at 
http://dpaste.dzfl.pl/


Re: Assert prints an array of char when used why to!string

2012-07-27 Thread novice2

BTW, in docs about text:

http://dlang.org/phobos/std_conv.html#text

...Convenience functions for converting any number and types of
arguments into text (the three character widths)... 

What is the three character widths note?
Who knows?


Re: Assert prints an array of char when used why to!string

2012-07-27 Thread novice2

Ah, thanks!

On Friday, 27 July 2012 at 14:47:49 UTC, Adam D. Ruppe wrote:

On Friday, 27 July 2012 at 14:40:33 UTC, novice2 wrote:

What is the three character widths note?
Who knows?


string, wstring, and dstring. Width refers to the bit size
of the char (8 bit, 16 bit, or 32 bit).





Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread novice2
templates are a tool for building static code from a set of 
parameters.


unfortunately (imho), there is no way to see the result code



Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread novice2
How it come, that we build another abstartion level above strong 
typed language?
Onece we builded high level language above assembler. Are we now 
building another more high level? Will temlate will become 
another language used as complete language? Will generic 
prigramming become mainstream, like high level languages today?


Re: Frontend and backend communication

2011-07-28 Thread novice2
Pelle Wrote:

 On Wed, 27 Jul 2011 19:41:37 +0200, Dainius (GreatEmerald)  
 You could use a struct of function pointers to define the interface, if

This is known approach in app, using plugin. For example, then open source FAR 
(File Archive Manager) exe load pluging dll, it fill strcuct with exe functions 
pointers, so plugin dll can use it


Re: Frontend and backend communication

2011-07-27 Thread novice2
Dainius (GreatEmerald) Wrote:

 No no. It's the other way round. Shuffle() is in the library
 (backend). PlaySound() is in the executable (frontend). Since I don't
 want the library to be dependent on any sound libraries, I can't have

would you pass playSound() as parameter (callback) to shuffle()?


Re: Library Documentation

2011-03-10 Thread novice2
Nicholas Wrote:

 As a result of (my) complaining and being a huge fan of XMind, I decided to
 try to organize the library for my own references as I encounter new sections
 of it.  I have a decent portion of it in place now.  I thought I'd post a link
 in case it can help anyone else out as well.
 
 
 http://polish.slavic.pitt.edu/~swan/theta/Phobos.xmind

may be you could expose/share your work via service like 

http://www.xmind.net/share/

because not everybody have installed xmind...


Re: problem while updating to 2.052

2011-02-20 Thread novice2
Jonathan M Davis, thank you for explanation,
but i am on windows :(


Re: Windows API Translation

2011-02-08 Thread novice2
  Wow, I didn't know this existed.  I wonder if these bindings would be
  suitable for inclusion in the core.sys.windows package?  Currently,
  core.sys.windows.windows only contains a small subset of the 

one bad (imho) thing - functions parameters names removed :( just types 
remains. it is make self-documentation or fast-look-to-remember harder :(


Re: Link with C static library

2011-01-16 Thread novice2
 Is it possible for D language to link with C static library under win32 
 platform?

yes, imho, it is possible. i successfully tried such thing with dev-cpp + gcc + 
coff2omf.

btw, coff2omf.exe says:

COFF to OMF Object Module Conversion Utility, Version 1.00.195
Copyright (C) 1994 by Walter Oney
All rights reserved


Re: phobos std.container example

2010-12-31 Thread novice2
thank you Ali and bearophile!



Re: Logger for D

2010-05-12 Thread novice2
sybrandy Wrote:

 
 https://launchpad.net/dlogger

thank you!

but why site says DLogger does not have any download files. ?


 - If compiled with -version=nologger, it's like you never included it.

may be it would be better -version=logger to compile with logger, and normal - 
without? what do you think? imho, compile with logger - not normal situation? i 
can be wrong of course...


Re: another d demoscene entry

2009-10-12 Thread novice2
  can i get opengl 2 as separate distro?
 Nope.

ok. nevermind.

 I'm sorry i don't think the demo will ever run on Intel.
 Maybe Intel does not support further release of OpenGL with your card, i 
 don't know.

no no, i am not request, just thinked it is bug


Re: Dynamic D Library

2009-07-16 Thread novice2
sorry, i don't understand: how D differ from C or C++ in all related to DLL in 
Windows? imho, only difference from MS VC is: VC have runtime in DLL form, but 
D have no.


std.process: bug or my fault?

2009-07-01 Thread novice2
I want to use Phobos
std.process.execv(in string pathname, in immutable(char)[][] argv)
to execute external programm with some parameter. But i found, that can't pass 
parameter properly - they not passed.
Here very short example - caller.exe shoud call called.exe with parameters:

/*** begin file caller.d */
import std.process;

void main()
{
  string[] args = [a1, b2, c3];
  std.process.execv(called.exe, args);
}
/*** end file caller.d */


/*** begin file called.d */
import std.file;
import std.string;

void main(string[] args)
{
  string s = std.string.join(args,  );
  std.file.write(called.log, s);
}
/*** end file called.d */


caller.exe execute called.exe with args a1 b2 c3,
then called.exe save this arguments to called.log file.

but in my environment(Windows XP sp3, DMD 2.030 and DMD 1.045) i have only 
called.exe b2 c3 in log file.
a1 argument missed.

Where i made mistake?
Can anyone reproduce?

thanks.


Re: std.process: bug or my fault?

2009-07-01 Thread novice2
thank you, Lars T. Kyllingstad
i will try to post it as windows-specific bug


Re: bitfields

2009-06-18 Thread novice2
Jarrett Billingsley Wrote:

 It's entirely possible to have two different C compilers
 output different code for the same bitfield definitions.  For that

Dut how is include files for interfacing is published officialy? For example 
Sun Java SDK .h files have bitfields to interfacing with java VM (without 
specifing wich compiler must be used).

OK. I get you point and ofcause will try to experiment (i will try to compare 
diasm of C and D versions).

thanx.


Re: static initialization of associative arrays

2009-04-15 Thread novice2
may be you can raplace string with char[] ?


Re: wchar[] and wchar*

2009-04-11 Thread novice2
Kagamin Wrote:

 
 this is readonly string. You can make it by simply appending \0.

sorry, but i not understand, what you wan to say to me :(
if you want - just say.
my original post was:
thank you Sergey

but sometime wchar* is zero-terminated strings (LPWSTR)
i feel lack of toStringz(wchar[]) and toString(wchar*) functions in phobos

what wrong? wich assertion is false?

for char[] -- char* interoperability in windows i used before the functions 
pair  std.windows.charset.toMBSz and fromMBSz.

and i just wanted to know, how i should act in the case wchar[] -- wchar*

are you want to say that thereis no problem at all?
wchar[] -- wchar* just append \0
wchar* -- wchar[] jusr ...?

bu i can fantasy long about what you want to say.

please, just advice me, how to write program in D with many D -- C (include 
Windows) interaction to keep D code simple.
some one in this forum advice me use wchar[] and no problem with Windows API. i 
just novice.


Re: wchar[] and wchar*

2009-04-09 Thread novice2
Kagamin Wrote:

 novice2 Wrote:
 
  but sometime wchar* is zero-terminated strings (LPWSTR)
 
 when?

everytime, when you see function with LPWSTR without size passing

for example:

SHGetFolderPathW(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR 
pszPath);

GetShortPathNameW( IN LPCWSTR lpszLongPath, OUT LPWSTR  lpszShortPath, IN DWORD 
cchBuffer);

GetLongPathNameW(IN LPCWSTR lpszShortPath, OUT LPWSTR lpszLongPath, IN DWORD 
cchBuffer);

etc etc etc



Re: wchar[] and wchar*

2009-04-08 Thread novice2
thank you, Denis


Re: Getting environment variables?

2008-11-23 Thread novice2
 homeDrive = toString(getenv(HOMEDRIVE)).dup;
 homePath = toString(getenv(HOMEPATH)).dup;

don't forget, that D char[] is utf8 and windows char* is 8-bit chars, not utf8.
so you should import std.windows.charset and use toMBSz() as D-WindowsAPI and 
fromMBSz as WindowsAPI-D string converter. for example:
homeDrive = fromMBSz(getenv(HOMEDRIVE)).dup;