Re: Source code for vibe.d listenTCP()

2022-03-08 Thread Chris Piker via Digitalmars-d-learn

On Sunday, 27 February 2022 at 01:45:35 UTC, Adam D Ruppe wrote:
My dpldocs.info search engine is not great right now but it can 
sometimes help find these things:


http://search.dpldocs.info/?q=listenTCP


Hi Adam

Your site has been super helpful given the state of the vibe.d 
docs.  It only has one issue from my point of view.  The source 
code listing pages, for example this one:


https://vibe-core.dpldocs.info/source/vibe.core.stream.d.html#L288

don't expand horizontally to use the given space in the browser 
window.


Since the vibe.d sources contain many long lines I have to scroll 
down, find the horizontal scroll bar at the bottom of the page, 
and then scroll back up and find the function I was looking at. 
Do you observe the same behavior in your preferred browser, or is 
this just a problem in Firefox 91?


No matter what, thanks for the site. I've been using it a lot!




Re: How to exclude function from being imported in D language?

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

On Tuesday, 8 March 2022 at 20:12:40 UTC, BoQsc wrote:
I think D Language needs and lacks conditional compilation 
condition and attribute of "exclude". The exclude keyword or 
code block in the exclude, would be made sure to not be 
imported by any means. Now it seems all to be only workarounds.


What D just needs is a way to specify the entry point, in which 
it just defaults to the first main function found, but could be 
any function given.


Re: How to exclude function from being imported in D language?

2022-03-08 Thread Ali Çehreli via Digitalmars-d-learn

On 3/8/22 12:12, BoQsc wrote:

> I think D Language needs and lacks conditional compilation condition and
> attribute of "exclude".

It may be so but this need wouldn't exist if either the first program 
were written in a modular way to begin with or have been refactored to 
be so as needed (at an earlier time or as you need it now):


- main.d contains main() and the high level program logic

- foo.d contains constructs that main.d uses

The other program is similar:

- main.d contains main() etc.

- bar.d imports 'foo' from the other program

I continuously refactor my programs in that way as they get more 
complicated and as parts of them get used by other programs.


> The exclude keyword

I am not aware of that feature in other languages.

Ali



Re: How to exclude function from being imported in D language?

2022-03-08 Thread BoQsc via Digitalmars-d-learn
I think D Language needs and lacks conditional compilation 
condition and attribute of "exclude". The exclude keyword or code 
block in the exclude, would be made sure to not be imported by 
any means. Now it seems all to be only workarounds.


Re: How to exclude function from being imported in D language?

2022-03-08 Thread Paul Backus via Digitalmars-d-learn

On Tuesday, 8 March 2022 at 17:47:47 UTC, BoQsc wrote:
Premise: In D language, only one main(){} function can exist in 
a program.

Having two `main()` functions throws an error.

Let's say I want to use some functionality of another program, 
but it has a `main(){}`
function. How can I import and use functions without importing 
the `main(){}` function?


You'll have to modify the other program to exclude the `main` 
function from compilation.


For example, you could use a [`version` condition][1]:

```d
module otherprogram;

version (Otherprogram_NoMain)
{
// no main function
}
else
{
void main(string[] args)
{
// ...
}
}

// other functions...
```

Then, when you're compiling the program that uses it, you can 
pass `-version=Otherprogram_NoMain` on the command line:


```
$ dmd -version=Otherprogram_NoMain myprogram.d otherprogram.d
```

This will include the `main` function from `myprogram.d`, but 
exclude the one from `otherprogram.d`.


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


How to exclude function from being imported in D language?

2022-03-08 Thread BoQsc via Digitalmars-d-learn
Premise: In D language, only one main(){} function can exist in a 
program.

Having two `main()` functions throws an error.

Let's say I want to use some functionality of another program, 
but it has a `main(){}`
function. How can I import and use functions without importing 
the `main(){}` function?