Re: Setting import paths - project (dub) and also rdmd or dmd

2022-10-01 Thread David via Digitalmars-d-learn

Thank you Steven and Christian.

I had a look at both those methods, creating a local dmd.conf 
file almost worked but it wasn't a simple modification, I was 
hoping it would be as simple as just adding the extra path but it 
seems that I needed to add the whole path from the existing 
dmd.conf otherwise the build broke due to not being able to find 
stuff, I added extra stuff but it was a clumsy solution...


Local dub packages I'm not not quite ready to do properly on this 
part of the learning curve and it is something I looked at and I 
think that I may end up using this.


In the end I cheated.  I simply added symlinks in my source 
directory to the *.d files I wanted to import and that solved the 
problem.


It's probably(certainly ?)  not the best way to do it but it 
works and as I become better with D I'm pretty sure I'll change 
it to something more sensible.


Regards,


D


Re: Poste some interesting vibe.d webpages

2022-09-20 Thread David via Digitalmars-d-learn
On Wednesday, 14 September 2022 at 19:34:01 UTC, Alain De Vos 
wrote:
Although the framework is good. There is no community. Or 
general acceptance. Which is a pitty.

Currently I ask myself how to do "sessions" with vibe.d.


Hi Alain,

I'm new to D and looking at vibe as well but I'm not as far down 
the path as settling on it as the final solution.


Have you looked at alternatives to vibe such as the hunt 
framework ?


https://code.dlang.org/packages/hunt-framework

It does seem better documented and fuller featured than vibe but 
that could be due to me not having an in-depth knowledge of 
either of them :-)


Regards,


D


Setting import paths - project (dub) and also rdmd or dmd

2022-09-19 Thread David via Digitalmars-d-learn

Hi,

New to D (and enjoying the learning..) I've probably missed 
something obvious but I'm slightly confused with the best way to 
achieve a simple build.


I like to keep my reusable modules in a directory outside of the 
project directory so I can use them on another project for 
example.


I do :-

import externalmodulename;

rdmd app.d and get a fail.

No problems, I can run rdmd thus :-

rdmd -I../EXTERNALMODULES app.d

and it all compiles nicely.

Same goes for dmd just use dmd -I and it compiles the code clean.

I'd normally just have a CPPFLAGS=... line in a classic Makefile 
to do this for me but can't see a native D way of doing it.  I 
looked at dub and that that :-


dub add-path ../EXTERNALMODULES

would do the trick but it doesn't make a difference (the path is 
added to the relevant json file in ~/.dub), I also tried 
add-local but no difference.  I was expecting it to add something 
to dub.sdl but that hasn't changed since I created the project.


TLDR: How do I automatically specify the -I to the compilers so I 
don't need to specify it manually each time ?



Regards,


D


Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-17 Thread David via Digitalmars-d-learn

On Wednesday, 17 March 2021 at 15:16:36 UTC, Jacob Carlborg wrote:
On Wednesday, 17 March 2021 at 13:52:48 UTC, Guillaume Piolat 
wrote:

On Sunday, 14 March 2021 at 11:33:00 UTC, David wrote:


Anyone else done this? Pointers welcome.


Sorry for delay.

Just add "dflags-osx-ldc": ["-static"],


macOS doesn't support static linking.

--
/Jacob Carlborg


Ah that's really useful to know, thanks - this is my first bit of 
macOS dev (other than high level stuff like R, Python, kdb etc) 
and I'm having to learn more about internals than I really care 
to - ho hum.


Re: How do I load dylib (i.e. phobos and druntime for ldc) in Macos sandboxed app?

2021-03-14 Thread David via Digitalmars-d-learn

On Sunday, 14 March 2021 at 11:40:25 UTC, David wrote:
This is more a macos thing than a D thing but still relevant. 
In another thread I was asking about cleaning up a D dylib for 
using in Excel. Ldc was suggested though first I have to figure 
out how to make the phobos and druntime loadable from within 
the sandbox.


(I've posted in a new topic as it was drift from the original 
question - hope that helps anyone else searching for the same 
answers).


I'm not expecting many relies - unless someone has happened to 
have solved it. Will post links once I've figured a solution.


Solved using install_name_tool and 
https://medium.com/@donblas/fun-with-rpath-otool-and-install-name-tool-e3e41ae86172









How do I load dylib (i.e. phobos and druntime for ldc) in Macos sandboxed app?

2021-03-14 Thread David via Digitalmars-d-learn
This is more a macos thing than a D thing but still relevant. In 
another thread I was asking about cleaning up a D dylib for using 
in Excel. Ldc was suggested though first I have to figure out how 
to make the phobos and druntime loadable from within the sandbox.


(I've posted in a new topic as it was drift from the original 
question - hope that helps anyone else searching for the same 
answers).


I'm not expecting many relies - unless someone has happened to 
have solved it. Will post links once I've figured a solution.


Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-14 Thread David via Digitalmars-d-learn

On Sunday, 14 March 2021 at 01:38:23 UTC, David Skluzacek wrote:

On Thursday, 11 March 2021 at 22:10:04 UTC, David wrote:
I wasn't aware that object files could be manipulated like the 
strip manual page - thx for the heads up.


With the caveats that the linked post is almost 14 years old, I 
can't try this command myself, and the ldc solution is probably 
preferable if you can get it to work - if you want to compile 
with dmd and use the strip command, this might help you (the OP 
answered his own question at the bottom):


https://forum.juce.com/t/how-to-build-dylib-exporting-only-wanted-symbols/2180

He suggests doing:

strip -u -r -s FILE_CONTAINING_EXPORTS_LIST MY_DYLIB.dylib


It looks straight forward that way - thx


Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-14 Thread David via Digitalmars-d-learn

On Sunday, 14 March 2021 at 00:00:59 UTC, Adam D. Ruppe wrote:

On Saturday, 13 March 2021 at 23:41:28 UTC, David wrote:
So Excel complains that it can't load my library - presumably 
because libphobos2 and libdruntime are not in the sandbox.ly


You *might* be able to compile with 
--link-defaultlib-shared=false to use the static 
phobos+druntime... but with shared libs it prefers shared and 
might not allow this. Probably worth a try.


Otherwise I'd try to just add the phobos so to your sandbox 
somehow. or the rpath set to current directory and putting them 
in your correct directory may also work. I don't know how that 
works on Mac but on Linux it is passing... `-L-rpath -L.` or 
something like that when compiling... I can't find my notes on 
this but something like that.


I think figuring out how to add phobos to the sandbox is probably 
the best option as I'm sure it won't be the last dylib I need to 
load.


Anyone else done this? Pointers welcome.


Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-13 Thread David via Digitalmars-d-learn

On Friday, 12 March 2021 at 00:12:37 UTC, Guillaume Piolat wrote:


Create a exports.lst file with:

_addDD_D


as the only line there.
Build with:

"lflags-osx-ldc": [ "-exported_symbols_list", "exports.lst", 
"-dead_strip" ],


Thx that's really helpful.

I've hit a snag with LDC. After serveral hours of searching and 
reading I think it's coming down to sandboxing and needing to 
deploy libraries in a place that excel can find them.


The library DMD creates just references 
/usr/lib/libSystem.B.dylib and Excel can load my dylib.


LDC on the other hand additionally references:

@rpath/libphobos2-ldc-shared.95.dylib (compatibility version 
95.0.0, current version 2.0.95)
@rpath/libdruntime-ldc-shared.95.dylib (compatibility version 
95.0.0, current version 2.0.95)


So Excel complains that it can't load my library - presumably 
because libphobos2 and libdruntime are not in the sandbox.ly


Can anyone (either tell me how to fix this) or give me pointers 
pls? (I'm current reading up on DYLD_LIBRARY_PATH (shouldn't use 
that), sandboxing on Mac, and rpaths)


I suppose a solution that allows the additional libraries to be 
put in a subdirectory of my library would be idea as then I can 
deploy that within the sandbox.


Thx for the help


Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn

On Thursday, 11 March 2021 at 18:35:37 UTC, Imperatorn wrote:

On Thursday, 11 March 2021 at 17:00:06 UTC, David wrote:

On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote:

On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote:

On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote:

[...]



[...]
Of course - but unless I've missed something I don't believe 
it works on macos.


Hmm, I'm not sure. Have you tried?


Nope the documentation implies it only works on windows so 
I've ruled it out. But the thing I'm trying to solve is 
suppression of symbols in the library.


I see, there might be something similar to .def?
https://docs.microsoft.com/en-us/cpp/build/reference/module-definition-dot-def-files?redirectedfrom=MSDN&view=msvc-160

Or I guess you could strip it?
https://www.linux.org/docs/man1/strip.html

But I guess you already thought of that and want to not even 
generate them in the first place?


I was wondering if there was something similar to def - my next 
attempt will be a combination of ldc and export.


I wasn't aware that object files could be manipulated like the 
strip manual page - thx for the heads up.


Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn

On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote:

On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote:

On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote:

On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote:
I thought it would be fun to convert some old C++/C quant 
utils to D. I'm starting with a simple library that I call 
from vba in Excel on macos:


[...]


*trigger warning*

"vba in Excel on macos" ⚠️

Btw, have you looked at excel-d?

https://code.dlang.org/packages/excel-d



Btw, have you looked at excel-d?
Of course - but unless I've missed something I don't believe 
it works on macos.


Hmm, I'm not sure. Have you tried?


Nope the documentation implies it only works on windows so I've 
ruled it out. But the thing I'm trying to solve is suppression of 
symbols in the library.


Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn
On Thursday, 11 March 2021 at 14:35:45 UTC, rikki cattermole 
wrote:

Pipe it to grep should work

| grep -v "__D2"


Thanks - though I'm trying to suppress the symbols being 
generated in the library.


A colleague says it can be done in ldc but not dmd. I'll think 
I'll try that out.


Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn

On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote:

On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote:
I thought it would be fun to convert some old C++/C quant 
utils to D. I'm starting with a simple library that I call 
from vba in Excel on macos:


[...]


*trigger warning*

"vba in Excel on macos" ⚠️

Btw, have you looked at excel-d?

https://code.dlang.org/packages/excel-d



Btw, have you looked at excel-d?
Of course - but unless I've missed something I don't believe it 
works on macos.






Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-11 Thread David via Digitalmars-d-learn
I thought it would be fun to convert some old C++/C quant utils 
to D. I'm starting with a simple library that I call from vba in 
Excel on macos:



module xlutils;

import core.stdc.string : strlen, strcpy;
//import std.conv : to;
//import std.string : toStringz;
import core.stdc.stdlib : malloc, free;

extern (C) double addDD_D(double a, double b) {return a + b;}
...


which results in:

nm -gU libxlutils.dylib
3f10 S __D7xlutils12__ModuleInfoZ
3e44 T _addDD_D
3ebc T _addrC
3e84 T _freeP
3e9c T _strcpyCC
3e6c T _strlenC_L


If I import `to` and `toStringz` I get more symbols than will fit 
in my shell output. E.g.


000318bc T 
__D2rt5minfo11ModuleGroup9sortCtorsMFAyaZ8findDepsMFmPmZ9__lambda5MFNbNiQBjZv
00031534 T 
__D2rt5minfo11ModuleGroup9sortCtorsMFAyaZ8findDepsMFmPmZb

00030dcc T __D2rt5minfo11ModuleGroup9sortCtorsMFAyaZv
00031db4 T __D2rt5minfo11ModuleGroup9sortCtorsMFZv
00048ef0 S __D2rt5minfo12__ModuleInfoZ
000327e4 T 
__D2rt5minfo16rt_moduleTlsCtorUZ14__foreachbody1MFKSQBx19sections_osx_x86_6412SectionGroupZi

...
000183ac T _thread_resumeAll
00018660 T _thread_scanAll
00018480 T _thread_scanAllType
00019658 T _thread_suspendAll


Is there a way of not exposing the symbols that aren't mine? - I 
only need a simple C interface.


Thx

David







Re: Memory allocation

2021-02-23 Thread David via Digitalmars-d-learn

On Wednesday, 24 February 2021 at 06:14:58 UTC, Imperatorn wrote:

On Tuesday, 23 February 2021 at 19:44:39 UTC, David wrote:

Not sure if `learn` is the right topic or not to post this..

I've been going through Bob Nystrom's "Crafting Interpreters" 
for a bit of fun and over the weekend put together a toy 
allocator in D - free and gc not yet done. It's single 
threaded and unsurprisingly faster than malloc for small 
objects up to 512 bytes, and about the same for larger objects 
(simulated with a linear distribution of size requests).


[...]


Have you looked at the "experimental" allocator(s) in D?

std.experimental.allocator


Hi, yes, good question, yes I did - my first cut using the 
mmap_allocator was slower - I presume because I should really 
allocate a good chunk of virtual memory and manage the pages 
myself.


So some questions I'm asking myself -

What people's heuristics for switching methods say from, some 
sort of pool to another approach - e.g. linked list of pages? At 
the page level does a bitmap allocator make more sense?


Knuth (it seems) was under the impression that a third of memory 
is wasted by fragmentation, aka the 50% rule - that doesn't seem 
likely, does anyone measure these things?


How does one go about choosing a set of pool sizes?

Given that virtual pages are not necessarily physically 
contiguous are some of the considerations that inspired the buddy 
system no longer relevant.


I should also say I'm aiming for a single thread longish running 
process (one +  working days) that I anticipate could use a good 
chunk say 100GB or so on occasion but I'd like to be more 
efficient than java in terms of memory reuse - past experience 
was I had to reboot my workstation a few times a day as it did 
something really horrible (I don't know what).



Any there any GC frameworks that someone has shared in D?



Memory allocation

2021-02-23 Thread David via Digitalmars-d-learn

Not sure if `learn` is the right topic or not to post this..

I've been going through Bob Nystrom's "Crafting Interpreters" for 
a bit of fun and over the weekend put together a toy allocator in 
D - free and gc not yet done. It's single threaded and 
unsurprisingly faster than malloc for small objects up to 512 
bytes, and about the same for larger objects (simulated with a 
linear distribution of size requests).


But I'd like to be able to benchmark it to see how I'm doing.

A colleague suggested I ask here for resources and pointers - I 
was trying to find stats on malloc performance (internal and 
external fragmentation, long running reuse, distributions of size 
requests for testing and comparison, how to reason about 
trade-offs of cache missing, branch misprediction, meta data, 
etc).


So academic papers, books, blogs, experiences are all welcome, 
especially with regard to optimising for immutability / COW - 
would be welcome or even just some good ol' conversation.






Re: do mir modules run in parallell

2019-10-06 Thread David via Digitalmars-d-learn

On Sunday, 6 October 2019 at 05:32:34 UTC, 9il wrote:
mir-blas, mir-lapack, and lubeck parallelism depend on system 
BLAS/LAPACK library (OpenBLAS, Intel MKL, or Accelerate 
Framework for macos).


mir-optim by default single thread but can use TaskPool from D 
standard library as well as user-defined thread pools.


mir-random was created for multithread programs, check the 
documentation for a particular engine. The general idea is that 
each thread has its own engine.


Other libraries are single thread but can be used in 
multithread programs with Phobos threads or other thread 
libraries.


Best,
Ilya


thanks! I will try it out accordingly.
Bests, David


Re: do mir modules run in parallell

2019-10-05 Thread David via Digitalmars-d-learn

On Saturday, 5 October 2019 at 04:38:34 UTC, 9il wrote:

On Friday, 4 October 2019 at 20:32:59 UTC, David wrote:

Hi

I am wondering if MIR modules run in parallel by default or if 
I can enforce it by a compiler flag?


Thanks
David


Hey David,

Do you mean unittests run in parallel or mir algorithms 
themselves run in parallel?


Ilya


Hi Ilya

Thanks for coming back on this and sorry for not being precise. I 
am wondering about the Mir algorithms.


David


do mir modules run in parallell

2019-10-04 Thread David via Digitalmars-d-learn

Hi

I am wondering if MIR modules run in parallel by default or if I 
can enforce it by a compiler flag?


Thanks
David


Re: mir.ndslice: assign a vector to a matrix row

2018-12-28 Thread David via Digitalmars-d-learn

On Friday, 28 December 2018 at 08:11:37 UTC, 9il wrote:

On Friday, 28 December 2018 at 08:09:09 UTC, 9il wrote:

On Thursday, 27 December 2018 at 21:17:48 UTC, David wrote:

On Wednesday, 26 December 2018 at 18:59:25 UTC, 9il wrote:

[...]


great many thanks!! Is there any logic why getting a row 
works by


auto row = matrix[0];

but assigning to a row works (only) by the two variant you 
posted?


This case gets a slice of a row, it does not copy the data. So 
row[i] is matrix[0, i], the same number in the RAM.


auto row = matrix[0];

This case gets a slice of a row, it does not copy the data.

If you wish to copy data you need to use a slice on the right 
side:




EDIT: a slice on the LEFT side


Many thanks for this background!!


Re: mir.ndslice: assign a vector to a matrix row

2018-12-27 Thread David via Digitalmars-d-learn

On Wednesday, 26 December 2018 at 18:59:25 UTC, 9il wrote:

On Saturday, 15 December 2018 at 19:04:37 UTC, David wrote:

Hi

I am wondering if it is possible to assign a vector to a row 
of a matrix?


 main.d ==
import mir.ndslice;

void main() {

  auto matrix = slice!double(3, 4);
  matrix[] = 0;
  matrix.diagonal[] = 1;

  auto row = matrix[0];
  row[3] = 4;
  assert(matrix[0, 3] == 4);

  // assign it to rows of a matrix?
  auto vector = sliced!(double)([10, 11, 12, 13]);

  // ??? Here I would like to assign the vector to the last 
(but it is not working)

  // matrix[2] = vector;
}


So I am wondering what the correct way is to do such an 
assignment without looping?


matrix[2][] = vector;

Or

matrix[2,0..$] = vector;


great many thanks!! Is there any logic why getting a row works by

auto row = matrix[0];

but assigning to a row works (only) by the two variant you posted?




Re: dscanner --ctags: local variables, functions, ... are now shown in vim/neovim Tagbar

2018-12-17 Thread David via Digitalmars-d-learn
On Monday, 17 December 2018 at 08:56:07 UTC, Laurent Tréguier 
wrote:
I think that's not possible right now, D-Scanner skips over 
body functions and unittest blocks to not clutter the tags with 
potentially lots of local names.


A pity; nevertheless many thanks for coming back on it!


dscanner --ctags: local variables, functions, ... are now shown in vim/neovim Tagbar

2018-12-16 Thread David via Digitalmars-d-learn
I am wondering how I could display (nested) local variables and 
functions in vim's tagbar (majutsushi/tagbar) using dscanner? So 
far I only see gloable variables, functions, ...


=== script.d ==
import std.stdio;

enum globalEnum1  { A = 1, B = 2 }
enum globalEnum2  { C, D }
void globalFun(){ writeln("global"); }
double globalDouble = 2.3;
string globalString = "hi";

void main(){
  enum localEnum  { A = 1, B = 2 }
  void localFun(){ writeln("local"); }
  double localDouble = 2.3;
}
===

=== Tagbar shows: ===
◢ functions
globalFun()
main()

◢ globalEnum1 : enum
[enumerators]
A
B

◢ globalEnum2 : enum
[enumerators]
C
D

◢ variables
globalDouble
globalString
===

" tagbar:
let g:tagbar_type_d = {
  \ 'ctagstype' : 'd',
  \ 'kinds' : [
  \ 'c:classes:1:1',
  \ 'f:functions:1:1',
  \ 'T:template:1:1',
  \ 'g:enums:1:1',
  \ 'e:enumerators:0:0',
  \ 'u:unions:1:1',
  \ 's:structs:1:1',
  \ 'v:variables:1:0',
  \ 'i:interfaces:1:1',
  \ 'm:members',
  \ 'a:alias'
  \ ],
  \'sro': '.',
  \ 'kind2scope' : {
  \ 'c' : 'class',
  \ 'g' : 'enum',
  \ 's' : 'struct',
  \ 'u' : 'union',
  \ 'T' : 'template',
  \},
  \ 'scope2kind' : {
  \ 'enum'  : 'g',
  \ 'class' : 'c',
  \ 'struct': 's',
  \ 'union' : 'u',
  \ 'template'  : 'T',
  \ },
  \ 'ctagsbin' : 'dscanner',
  \ 'ctagsargs' : ['--ctags']
\ }




mir.ndslice: assign a vector to a matrix row

2018-12-15 Thread David via Digitalmars-d-learn

Hi

I am wondering if it is possible to assign a vector to a row of a 
matrix?


 main.d ==
import mir.ndslice;

void main() {

  auto matrix = slice!double(3, 4);
  matrix[] = 0;
  matrix.diagonal[] = 1;

  auto row = matrix[0];
  row[3] = 4;
  assert(matrix[0, 3] == 4);

  // assign it to rows of a matrix?
  auto vector = sliced!(double)([10, 11, 12, 13]);

  // ??? Here I would like to assign the vector to the last (but 
it is not working)

  // matrix[2] = vector;
}


So I am wondering what the correct way is to do such an 
assignment without looping?





Re: working with and installing multiple versions of dmd and D's std-library on linux/ubuntu

2017-01-20 Thread David via Digitalmars-d-learn
Many thanks! dvm works as a dream and I will also give Coedit a 
try





working with and installing multiple versions of dmd and D's std-library on linux/ubuntu

2017-01-20 Thread David via Digitalmars-d-learn

Hi

I am wondering what a good strategy would be to install and work 
with multiple versions of DMD and the associated standard library 
on Linux/Ubuntu? The background is that for some features and 
libraries I need another compiler/std-lib version than for 
others. So having the opportunity to choose the compiler and the 
associated std-lib manually would be nice.


David


Re: Address of an array

2016-10-27 Thread David via Digitalmars-d-learn

A dynamic array looks something kind of like this:

struct DynamicArray(T)
{
size_t length;
T* ptr;
}

So, if you take the address of a dynamic array, you're 
basically taking the address of a struct on the stack, whereas 
the address in ptr is the address in memory where the data is 
(be it GC-allocated memory, malloc-ed memory, or a static array 
on the stack somewhere).


Similarly, if you have a class reference, and you take its 
address, you're taking the address of the reference, not the 
class object that it points to. e.g.


class MyClass
{
string foo;
}

MyClass mc;
auto addr = &mc;

addr is the address of mc on the stack, whereas mc itself is 
null.


- Jonathan M Davis


Many thanks for your speedy and clear answer Jonathan! That makes 
even sense to me :-)




Re: Address of an array

2016-10-27 Thread David via Digitalmars-d-learn

On Thursday, 27 October 2016 at 16:13:34 UTC, David wrote:

Hi

The pointer (.ptr) of an array is the address of the first 
array element. But what exactly is the address of the array? 
And how is it used?


  auto myArray = [5, 10, 15, 20, 25, 30, 35];
  writeln("myArray.ptr: ", myArray.ptr); // myArray.ptr: 
7FFA95F29000
  writeln("&myArray[0]: ", &myArray[0]); // &myArray[0]: 
7FFA95F29000

  writeln("&myArray: ", &myArray); // &myArray: 7FFE4B576B10
  writeln("*&myArray: ", *&myArray); // *&myArray: [5, 10, 15, 
20, 25, 30, 35]


Sorry that went to quickly ;-)

I observe for example that the even if the pointer is moved to 
another address the address of the (dynamic) array stays constant:


  auto shrink = myArray[0 .. $-1];
  writeln("shrink.ptr: ", shrink.ptr);
  writeln("&shrink: ", &shrink);

Note: myArray and shrink have the same ptr but a different address

  shrink ~= 100;
  writeln("shrink.ptr: ", shrink.ptr);
  writeln("&shrink: ", &shrink);

Note: After appending, shrink changes its ptr but its address 
stays the same.


Thanks for your help in advance.



Address of an array

2016-10-27 Thread David via Digitalmars-d-learn

Hi

The pointer (.ptr) of an array is the address of the first array 
element. But what exactly is the address of the array? And how is 
it used?


  auto myArray = [5, 10, 15, 20, 25, 30, 35];
  writeln("myArray.ptr: ", myArray.ptr); // myArray.ptr: 
7FFA95F29000
  writeln("&myArray[0]: ", &myArray[0]); // &myArray[0]: 
7FFA95F29000

  writeln("&myArray: ", &myArray); // &myArray: 7FFE4B576B10
  writeln("*&myArray: ", *&myArray); // *&myArray: [5, 10, 15, 
20, 25, 30, 35]













Game Development Using D

2016-05-21 Thread David via Digitalmars-d-learn

Hi,

I want to try to create a game using D. I'm a complete newbie 
though (other than having C/C++ experience). Where would I start? 
Does D have an openGL binding? I am assuming I'll need to 
leverage a good amount C APIs? Any list of these that would be 
useful it a game setting?


Obviously this all depends on *how* much work I want to do. 
Ideally, I'd like a collection of tools that will get me roughly 
the equivalent of what XNA provides.


Re: Programming a Game in D? :D

2014-08-31 Thread David via Digitalmars-d-learn

Hi,
About 2 month ago I started learning modding for minecraft with 
the Forge API
I was reading through a lot of classes of minecraft and even no 
it might not seem like, I learned a freking lot about how games 
work and stuff and improved my programming skill a lot (Yes for 
Java but also overall)
So now, I want to come back to my own game with a lot of 
questions :P
So first of all, I'm not sure if D is really the best choice for 
me. Since its just pretty hard for begginers like me without any 
tutorials and anything to come up with a game. Then what language 
should it be? It should have a big community around and be a good 
language for games (fast) and it should not be called C++.
And I know you told me it would be a better idea to get going 
first with easier tools like gamemaker or something like that, 
but I seriously don't want to come up with something big anyway 
and if i fail completly I don't mind.
And finally, (now thats going far away from the actual point and 
maybe thats even the wrong forum for that) how is wrapping 
working? lets say I wrote a method methodA in Java in ClassA and 
wanted to use MethodA in D, how would I go about doing this? 
(Well, is a wrapper actually doing what I think?).

David = still a fool.


Re: Programming a Game in D? :D

2014-08-02 Thread David via Digitalmars-d-learn
Hi, not too sure if there's still someone reading this post, but 
i do have another question. So, I heared so much good stuff about 
D, it's powerfull, fast the syntax is nice, but well, why is D 
actually not used for common games yet? (I mean I know about some 
smaller projects, but nothing "big")


Re: Programming a Game in D? :D

2014-05-28 Thread David via Digitalmars-d-learn
On Wednesday, 28 May 2014 at 21:38:07 UTC, Francesco Cattoglio 
wrote:


I'll be honest, perhaps I risk being misunderstood, but the 
questions you are asking denote a lack of even basic knowledge 
about the subject, so I really think you should do some good 
amount of research before even trying to write something on 
your own.




Well, I really don't have a lot of knowledge but I don't know 
where to start.
The Problem is just that there is sooo much stuff in the internet 
and it's kinda hard to get some knowledge.


Have you tried at least some free tools that allow you to 
script stuff and have simple stuff displayed on screen? I'm 
talking about stuff like Construct 2, GameMaker, RPGMaker, 
zGameEditor... even map editors like the ones from Blizzard 
(WarCraft 3 : TFT or StarCraft 2)?


So, i made a very little game with delphi Genesis3D and an Editor 
i don't remember about 2 years ago, but i don't know if i really 
knew what i was doing there :P


Re: Programming a Game in D? :D

2014-05-28 Thread David via Digitalmars-d-learn

On Tuesday, 27 May 2014 at 10:13:13 UTC, Szymon Gatner wrote:

On Tuesday, 27 May 2014 at 10:03:36 UTC, David wrote:

On Saturday, 24 May 2014 at 08:54:53 UTC, ponce wrote:


Hi David,

Learning programming, learning D and learning 3D are 3 
significant endeavours.
You might want to begin with http://www.basic4gl.net/ which 
will get you going with 3D, quite a topic in itself.

Then learn D regardless :)


So, I'v used Blender for a half year or sth. and I think I can 
make a little area :)
As far as I know, I do now need a graphic and physics engines, 
1 of the graphic APIs and for sure my programming stuff and 
here I'm stuck :D


And I still can't install Mono-D :( if I try I just get a 
whole bunch of errors that any packages couldn't be found, 
don't know if I'm doing sth. wrong

(I probably do :P)


I would STRONGLY advise to go with a ready engine like Unity.

You still have to learn a lot before you  will have just 
building blocks to create a game like loading and rendering 3D 
models, a gameplay framework etc etc.


Start with Unity, lean how to make a game there. Learn how to 
programm gameplay there and after that, when you see what is 
needed before even being able to make a game, only then try to 
make things from scratch. Use C# in Unity too as it is similar 
to D so you will have easier transition when necessary.


Ok, now I just wonder wich Engine. (I know everybody hates the
discussion about the "best" engine.) CryEngine, UDK, Unity or a
less known Engine?


Re: Programming a Game in D? :D

2014-05-27 Thread David via Digitalmars-d-learn

On Saturday, 24 May 2014 at 08:54:53 UTC, ponce wrote:


Hi David,

Learning programming, learning D and learning 3D are 3 
significant endeavours.
You might want to begin with http://www.basic4gl.net/ which 
will get you going with 3D, quite a topic in itself.

Then learn D regardless :)


So, I'v used Blender for a half year or sth. and I think I can 
make a little area :)
As far as I know, I do now need a graphic and physics engines, 1 
of the graphic APIs and for sure my programming stuff and here 
I'm stuck :D


And I still can't install Mono-D :( if I try I just get a whole 
bunch of errors that any packages couldn't be found, don't know 
if I'm doing sth. wrong

(I probably do :P)


Re: Programming a Game in D? :D

2014-05-24 Thread David via Digitalmars-d-learn

On Saturday, 24 May 2014 at 09:49:30 UTC, evilrat wrote:

On Saturday, 24 May 2014 at 09:35:01 UTC, David wrote:

On Friday, 23 May 2014 at 17:47:56 UTC, evilrat wrote:


why not just use Xamarin Studio with Mono-D?


But only the trial of Xamarin Studio is for free, and I used 
eclipse for Java before and really like it :P


actually not. you don't even need to register at all. just go 
to http://monodevelop.com and get ur XS without all this fancy 
mobile stuff.


So I installed that Xamarin studio (hope i had to), what to do 
with the mono D thing now?

don't know hot to install it :P


Re: Programming a Game in D? :D

2014-05-24 Thread David via Digitalmars-d-learn

On Friday, 23 May 2014 at 17:47:56 UTC, evilrat wrote:


why not just use Xamarin Studio with Mono-D?


But only the trial of Xamarin Studio is for free, and I used 
eclipse for Java before and really like it :P


Re: Programming a Game in D? :D

2014-05-23 Thread David via Digitalmars-d-learn

On Friday, 23 May 2014 at 14:11:26 UTC, David wrote:

Ok so I installed DDT for eclipse now but have a problem :D
First the imports are changed, std.studio is now std.stdio (or 
its something completly else)
And if I try to run the file now it says that the exe file of 
my file doesn't exsist wich I actully thought I creat by 
clicking on run?

In Java it was just pressing run.. :/

actually no it was std.stdio before too :D woops
but wont solve my problem with getting it run



Re: Programming a Game in D? :D

2014-05-23 Thread David via Digitalmars-d-learn

Ok so I installed DDT for eclipse now but have a problem :D
First the imports are changed, std.studio is now std.stdio (or 
its something completly else)
And if I try to run the file now it says that the exe file of my 
file doesn't exsist wich I actully thought I creat by clicking on 
run?

In Java it was just pressing run.. :/


Programming a Game in D? :D

2014-05-22 Thread David via Digitalmars-d-learn
Hey, I'm really new to D, and pretty new to programming overall 
too,
But I want to make a 3d Game, (just sth. small). I really like D 
and want to do it in D, but in the Internet there is no shit 
about programming a game in D ^^

Is there any engine written in D?
For example the CryEngine is for C++, so I would have to write a 
wrapper?
So, how do I write a wrapper? I would need a wrapper for DirectX 
too right?

Are there any wrappers ore Engines for D i can use?
btw. I know I dont write that in 1 day ^^
Are there any tutorials or sth. on Programming a Game in D?
S I just wanna come as far to have a little Cube where i 
can run around on with a few phisics :) so just the startup to 
load a world and so on

Thanks in advance :)
And sry my english sucks :D


Re: DMD & Deimos || GDC & Deimos?

2014-04-27 Thread David via Digitalmars-d-learn
Am 26.04.2014 20:18, schrieb Entry:
> I'd like to use GLFW from Deimos, but I couldn't get it to work (DMD
> said it cannot use libglfw.a) and I've read somewhere that only GDC can
> use these DLLs directly (with a D header, but that's still better than
> hooking the methods). So do I need GDC for that or not? And would you
> actually recommend it?
> 
> On a side note, getting GDC to work is a bitch. I had to copy around
> several DLLs (like libiconv-2.dll) and it's now working only with the
> libgcc_s_sjlj-1.dll copied right next to my application's exe. What am I
> doing wrong?
> 
> This is really frustrating :/



I have a 10 month old glfw3.dll

https://github.com/Dav1dde/BraLa/tree/master/lib/win

Since glfw didnt change much (that was already at release), this is
probably enough for you. Simply pass the glfw3.lib to the compiler and
make sure glfw3.dll is reachable in runtime.

But you can also build your own using cygwin (that's how I made it) and
use implib for format conversion.