Re: How to import & export modules

2019-11-10 Thread Mike Parker via Digitalmars-d-learn

On Monday, 11 November 2019 at 01:28:54 UTC, userTY wrote:



import all; // can see App, Form and Button exported (public) 
symbols

---


The approach of using an "all" module is an old hack that is no 
longer necessary. Today, the way to approach is to use a "package 
module".


https://dlang.org/spec/module.html#package-module

Given a package "mylib" containing multiple modules, create a 
file "mylib/package.d". Use the package name as the module name 
and follow it with your public imports:


module mylib;

public import mylib.foo, mylib.bar, mylib.baz;

Then users of the package can simply:

import mylib;




Re: How to import & export modules

2019-11-10 Thread Arun Chandrasekaran via Digitalmars-d-learn

On Monday, 11 November 2019 at 01:28:54 UTC, userTY wrote:
On Sunday, 10 November 2019 at 23:53:22 UTC, Vinod K Chandran 
wrote:

[...]


You must use a module that has public imports.
Public imports are visible from the module that contain them 
but most importantly from the module that imports the module 
containing the public imports.


---
module all;

public import App, Form, Button;
---

---
module app;

import all; // can see App, Form and Button exported (public) 
symbols

---

See the specifications [1] for more comprehenssive details.

[1]: https://dlang.org/spec/module.html#public_imports


Just a nitpick, prefer to use D style: 
https://dlang.org/dstyle.html


Modules are essentially files. So keeping them lower case makes 
it easier.


Re: How to import & export modules

2019-11-10 Thread userTY via Digitalmars-d-learn
On Sunday, 10 November 2019 at 23:53:22 UTC, Vinod K Chandran 
wrote:

Hi all,
I am practicing D by writting a win API gui wrapper. I want to 
use a single module import to use this Gui lib. Say i have 10 
modules like--
"App.d, Form.d, Button.d, Label.d, TextBox.d, ComboBox.d, 
ListBox.d, CheckBox.d, Panel.d, DateTimePicker.d"
In Nim, i can import and export all these modules in a separate 
single module and then i only need to use that module. Say i 
have a special module named "GuiLib.nim" And inside that  if i 
write like this--

import
App
Form
Button


export
import
App
Form
Button


Then in my main file, i only need to import the "GuiLib". How 
is this possible in D ?


You must use a module that has public imports.
Public imports are visible from the module that contain them but 
most importantly from the module that imports the module 
containing the public imports.


---
module all;

public import App, Form, Button;
---

---
module app;

import all; // can see App, Form and Button exported (public) 
symbols

---

See the specifications [1] for more comprehenssive details.

[1]: https://dlang.org/spec/module.html#public_imports


How to import & export modules

2019-11-10 Thread Vinod K Chandran via Digitalmars-d-learn

Hi all,
I am practicing D by writting a win API gui wrapper. I want to 
use a single module import to use this Gui lib. Say i have 10 
modules like--
"App.d, Form.d, Button.d, Label.d, TextBox.d, ComboBox.d, 
ListBox.d, CheckBox.d, Panel.d, DateTimePicker.d"
In Nim, i can import and export all these modules in a separate 
single module and then i only need to use that module. Say i have 
a special module named "GuiLib.nim" And inside that  if i write 
like this--

import
App
Form
Button


export
import
App
Form
Button


Then in my main file, i only need to import the "GuiLib". How is 
this possible in D ?


Re: (SOLVED) requests module generates " Can't parse uri '' "

2019-11-10 Thread ikod via Digitalmars-d-learn

On Sunday, 10 November 2019 at 01:28:13 UTC, cartland wrote:

On Saturday, 9 November 2019 at 01:02:57 UTC, cartland wrote:

On Saturday, 9 November 2019 at 00:53:13 UTC, cartland wrote:

On Friday, 8 November 2019 at 17:01:07 UTC, ikod wrote:
*snip*
Even this does it.

import requests;
void main() {
}


https://github.com/ikod/dlang-requests/issues/109


Figured it out. See github issue. I had http_proxy env var set 
to blank. Worked when I unset it.


Thanks for report, fixed in latest release.


Re: DMD release compiler flags when building with GDC

2019-11-10 Thread Per Nordlöw via Digitalmars-d-learn

On Sunday, 10 November 2019 at 15:59:22 UTC, Johannes Pfau wrote:
I think -flto is the proper flag for GCC/GDC. I don't know if 
LTO is working though. A long time ago there were some bugs, 
but maybe that's been fixed. You probably just have to try and 
see ;-)


Thanks


Re: DMD release compiler flags when building with GDC

2019-11-10 Thread Johannes Pfau via Digitalmars-d-learn
Am Sat, 09 Nov 2019 20:43:20 + schrieb Per Nordlöw:

> I've noticed that the make flag ENABLE_LTO=1 fails as
> 
>  Error: unrecognized switch '-flto=full'
> 
> when building dmd with GDC 9.
> 
> Does gdc-9 support lto? If so what flags should I use?
> 
> If not what are the preferred DFLAGS when building dmd with gdc?


I think -flto is the proper flag for GCC/GDC. I don't know if LTO is 
working though. A long time ago there were some bugs, but maybe that's 
been fixed. You probably just have to try and see ;-)


-- 
Johannes


Re: Small program producing binary with large filesize

2019-11-10 Thread Jacob Shtokolov via Digitalmars-d-learn

On Monday, 21 October 2019 at 19:20:04 UTC, Prokop Hapala wrote:
What exactly should I specify to make it link dynamcially and 
produce as small binary as possible (without increasing 
compilation time) ?


Hi! Sorry, just found your response here. In order to force it to 
link dynamically, add these lines to your `dub.json`:


```
"buildTypes": {
"release-shared": {
"dflags": ["-link-defaultlib-shared", "-release", "-O3"]
}
},
"postBuildCommands": [
"strip ./"
]
```

Then build it like that:

```
dub build --build=release-shared --compiler=ldc2
```

Make sure that you replace  under `postBuildCommands` 
with your own application (binary) name.


The thing is that LDC2 links statically by default, so you have 
to add a few flags to the command line


Re: Is there any writeln like functions without GC?

2019-11-10 Thread dangbinghoo via Digitalmars-d-learn

On Sunday, 3 November 2019 at 05:46:53 UTC, 9il wrote:

On Thursday, 31 October 2019 at 03:56:56 UTC, lili wrote:

Hi:
   why writeln need GC?


See also Mir's @nogc formatting module

https://github.com/libmir/mir-runtime/blob/master/source/mir/format.d


hi, is mir right now fully implemented using betterC?

thanks!
--
binghoo