Re: Is std.variant.visit not @nogc?

2018-04-09 Thread Hasen Judy via Digitalmars-d-learn

On Monday, 9 April 2018 at 03:41:17 UTC, Adam D. Ruppe wrote:

On Monday, 9 April 2018 at 03:20:58 UTC, helxi wrote:

visit, being a template, is @nogc or not based on the arguments 
passed to it as well as its own body, so while the error 
messages point to visit itself, these are frequently actually 
caused the predicate your pass.


[]

std.variant.VariantException.this is not marked @nogc (but it 
prolly could be)


VariantN.peek is not @nogc because it calls Object.opEquals... 
which is broken af, sadly, but can probably be fixed for this 
case by marking TypeInfo.opEquals nogc.





IMO, this is one more reason why sum-types should be built into 
the language compiler, instead of being implemented in user-space.


Re: Web servers in D

2017-11-28 Thread Hasen Judy via Digitalmars-d-learn

On Tuesday, 12 September 2017 at 12:34:26 UTC, aberba wrote:

On Friday, 25 August 2017 at 05:25:09 UTC, Hasen Judy wrote:
What libraries are people using to run webservers other than 
vibe.d?


Don't get me wrong I like the async-io aspect of vibe.d but I 
don't like the weird template language and the fact that it 
caters to mongo crowd.


I think for D to a have good web story it needs to appeal to 
serious backend developers, not hipsters who go after fads 
(mongodb is a fad, jade/haml is a fad).


I probably need to combine several libraries, but the features 
I'm looking for are:


- Spawn an HTTP server listening on a port, and routing 
requests to functions/delegates, without hiding the details of 
the http request/response objects (headers, cookies, etc).


- Support for websockets

- Runs delegates in fibers/coroutines

- Basic database connectivity (No "orm" needed; just raw sql).

- When iterating the result set of a sql query, has the 
ability to automatically map each row against a struct, and 
throw if the structure does not match.


- More generally, map any arbitrary object (such as json) to a 
struct. Something like Zewo/Reflection package for swift[0].


[0]: https://github.com/Zewo/Reflection

I feel like Vibe.d satisfies my first 3 requirements, but for 
the rest I will probably have to look for something else.


In 2017, backend developers are more likely to write 
microservices which expose rest/graphQL APIs and put them in 
dockers containers Unless you're a full stack developer, 
you'll not be using jade/diet (at least not enough to be 
tempted to use something else).


Its still sucks there's no object storage api for D. Are you 
guys still building monolithic web servers?


Sorry this is an incredibly late response.

Come on now, in CURRENT_YEAR people are jumping and this year's 
fad train. I don't want to jump along, thank you very much.


And I don't understand this containers business. As far as I can 
tell it was designed for interpreted languages because they tend 
to have a lot of very specific dependences that are a hell to 
manage.


If the compiler can produce a statically linked binary, then 
there's no problem that a container would solve here.


Ranges seem awkward to work with

2017-09-11 Thread Hasen Judy via Digitalmars-d-learn
Is this is a common beginner issue? I remember using an earlier 
version of D some long time ago and I don't remember seeing this 
concept.


Now, a lot of library functions seem to expect ranges as inputs 
and return ranges as output.


Even parsing a csv line returns a range. And the funny thing is, 
once you loop over it, it's done. You've basically consumed it.


For example, I was having some trouble with the api of the 
std.csv module, so to help me debug, I printed the result of the 
csv. ok, the result seems good. Now I try to use it, for example:


auto name = row[1];

And to my surprise there's a runtime error, something about range 
something something. I don't even remember what the error was. 
The thing is, it wasn't clear what was going on.


The line was actually more like:

auto some_var = 
some_function(row[1].some_other_library_method!template_variable);


So because I was calling several library methods on the same 
line, I thought the problem might have something to do with the 
range not exactly matching what the library was expecting. I 
thought maybe row[1] also returned some range instead of a string 
and that range had something wrong with it.


Well, it turned out that my earlier attempt to print the parsed 
csv row resulted in the row being "consumed" and now the row is 
an empty range(!).


Is there a straight forward way to convert a Range to a list 
other than manually doing a foreach?


string[] items;
foreach(item; someRangeThing) {
items ~= item;
}

I feel like that is a bit of an overkill.


Re: Web servers in D

2017-09-11 Thread Hasen Judy via Digitalmars-d-learn
On Saturday, 2 September 2017 at 09:26:27 UTC, Andrew Chapman 
wrote:



[...]


Don't use these components :-)


[...]


Vibe.d does this - just don't use the automatic API generation 
feature if you don't like it.  Note, you can get access to the 
request/response objects even if you do use the API generation 
by using an @before method.  E.g. in an interface you may have 
something like this:


[...]


Thanks for your response. I didn't see the new replies because I 
wrote the original message before I signed up on the site forum 
(I'm using the site, not an email program).


Re: Building (and including libraries) without dub

2017-08-26 Thread Hasen Judy via Digitalmars-d-learn

On Saturday, 26 August 2017 at 10:02:03 UTC, drug wrote:

It's like C++. If you use Linux then:
```
dmd  -L/path/to/lib 
-llibrarynamewithoutlibprefix

```
or example
```
dmd myapp.d -L../otherproject/lib -lcool
```
line above compiles `myapp.d` file and links it with library 
`libcool` that is place in directory `../otherproject/lib`


Thanks for your response!

So if I may make a guess, when you include a dependency in a dub 
project, what it ends up doing is compiling the dependency 
separately into a lib file then statically link the lib with your 
project?


Building (and including libraries) without dub

2017-08-26 Thread Hasen Judy via Digitalmars-d-learn
Building simple programs without dub is easy, just pass a list of 
.d source files to `dmd` or `ldc2`.


What if I want to include a 3rd party library? Surely before dub 
existed, people were incorporating other libraries in their 
projects.


I want to learn how this works from first principles. I've been 
working with dynamic/interpreted languages for too long, I forgot 
what it's like to build native programs without a dependency 
manager.


Any help would be appreciated!


Re: Web servers in D

2017-08-25 Thread Hasen Judy via Digitalmars-d-learn

On Friday, 25 August 2017 at 06:15:35 UTC, Eugene Wissner wrote:


There is collie [1]. Never used. Can't say a lot about it.

arsd [2] has a lot of interesting web stuff: event loop, 
FastCGI/SimpleCGI; web-, DOM-, mail-utilities.


And the last but not least I'm running currently a small web 
server serving static files based on tanya [3]. Once I'm ready 
to write a web-framework on top of it, it would be what you 
mention: no compile-time templates, no jade-style templates, 
since I dislike these too. But unfortunately it is not 
something can be used now.


[1] https://github.com/huntlabs/collie
[2] https://github.com/adamdruppe/arsd
[3] https://github.com/caraus-ecms/tanya


Thanks. Those are some interesting links.

FWIW I kind of like compile-time templates. I just don't like 
jade (or coffee-script, or stylus, or all these languages that 
try to remove the punctuation and curly braces, and all signs of 
structure).


Web servers in D

2017-08-24 Thread Hasen Judy via Digitalmars-d-learn
What libraries are people using to run webservers other than 
vibe.d?


Don't get me wrong I like the async-io aspect of vibe.d but I 
don't like the weird template language and the fact that it 
caters to mongo crowd.


I think for D to a have good web story it needs to appeal to 
serious backend developers, not hipsters who go after fads 
(mongodb is a fad, jade/haml is a fad).


I probably need to combine several libraries, but the features 
I'm looking for are:


- Spawn an HTTP server listening on a port, and routing requests 
to functions/delegates, without hiding the details of the http 
request/response objects (headers, cookies, etc).


- Support for websockets

- Runs delegates in fibers/coroutines

- Basic database connectivity (No "orm" needed; just raw sql).

- When iterating the result set of a sql query, has the ability 
to automatically map each row against a struct, and throw if the 
structure does not match.


- More generally, map any arbitrary object (such as json) to a 
struct. Something like Zewo/Reflection package for swift[0].


[0]: https://github.com/Zewo/Reflection

I feel like Vibe.d satisfies my first 3 requirements, but for the 
rest I will probably have to look for something else.