Re: Browsers in D

2023-12-19 Thread Antonio via Digitalmars-d-announce

On Tuesday, 19 December 2023 at 23:40:48 UTC, Antonio wrote:


Really? It is my primary development browser. ...


I apologize for the tone of my last post. I consider that what it 
express does not fit the rules of this forum.

If possible, I would like it to be removed by the moderator.
Thanks in advance.



Re: Browsers in D

2023-12-19 Thread Antonio via Digitalmars-d-announce

On Tuesday, 19 December 2023 at 21:15:19 UTC, Adam D Ruppe wrote:

With Firefox getting worse by the year, you might want to 
consider also making your own partially-usable chromium/edge 
skin (also known as "pukes")!


Really? It is my primary development browser.  In fact, chromium 
has left me in the lurch more than once with its bugs (mainly 
with svg and resources memory management).


Imagine a company with products based on svg (complex ones with a 
lot of user interaction) and a new version of chrome that fails 
managing mouse events in some circunstances... my company begun 
to receive emails/phone calls from our customers telling that 
"our software bug" was making them lose thousands of euros every 
hour.  (Our company was a "personalization" service used by a lot 
of manufacturers eCommerce in Spain).


It was not the first neither the last problem that a new version 
of chrome caused to our company:  You can't say to a customer 
"tell your users to browse your ecommerce with Firefox or Safari" 
because Chromium dominates browsers market (it is a monopolistic 
control).


I remember when reported a bug about canvas/images memory leak 
(Our software processed hundred of images directly on web)... we 
find the solution to assigning 0 to width/height... but the 
chromium bug remained YEARS until it was solved.  It gives you 
the magnitude of what a monopolistic control signifies.


Adam, I really heated Chrome... and I simply don't tolerate each 
new browser based on chromium. I consider it a giant error.  "One 
ring to rule them all"


Firefox protection is a must.





Re: implicit-context v0.0.1

2023-10-05 Thread Antonio via Digitalmars-d-announce

On Friday, 29 September 2023 at 08:33:56 UTC, Imperatorn wrote:
On Thursday, 28 September 2023 at 23:28:02 UTC, Guillaume 
Piolat wrote:

Hi,

Ever had a bit of feature-envy about Odin's "context" feature 
[1]? It is something used to pass "contextual" parameters, 
like a logger, an allocator, to callees. It is akin to Scala's 
"implicit parameters", or Jai contexts [2].


[...]


Interesting, what are the benefits of using this instead of 
global variables?


Context is dynamically generated/destroyed.  I developed this 
Idea in 2009 with c#. We named this  "functional context" (15 
years ago)... I found out later something similar with AOP 
(Aspects Oriented Programming) when working with Spring in java


Lets see an example

```d
long create(PersonDto person) =>
  withTransaction( (auto cnx){
// Perform person creation stuff
long personId = cnx.execute(
   "insert into people ... returning id",
   [...]
).first!long("id");
return personId;
  });

long create(CustomerDto customer) =>
  withTransaction( (auto cnx){
 long personId = create( customer.person );
 long customerId = cnx.execute(
   "insert into customers ... returning id",
   [personId, ... ]
 ).first!long("id");
 return customerId;
  });

void main(){
  withContext((){
CustomerDto customer = { code:"P001", 
person:{name:"Peter", nif:"3442543211F"}};

long customerId = create( customer );
  })
}
```

The "withTransaction" function, iternally, asks the context if 
there is an opened transaction.


* If not found:
*  It creates one and registers it into the context.
*  calls the delegate
*  commits the transaction and removes it from the context
*  returns the delegate result.
*  If an exception is thrown by the delegate, then the 
transaction is rollbacked instead commited and the exception is 
passed through to the caller.


* If found:
* Calls the delegate transparently and returns it's result


This use case of "implicit-context" works naturally in a "per 
thread context".



Stackability is nice: (this example is not so real, but a "how 
to" example):


```d
void createPersonAction() =>
  withHttpResponse( res =>
  withAuthentifiedUser( user =>
  withHttpBody!Person( person =>
  withLogger("createPersonAction", (logger) {
logger.info("Something to be logged");
auto id = withTransaction( cnx => cnx.execute(...) );
res.send(id) )
  });
```
It shoud be more natural this way ...

```d
void createPersonAction() =>
  with( auto res = implicitHttpResponse())
  with( auto user = implicitAuthentifiedUser())
  with( auto person = implicitHttpBody!Person())
  with( auto logger = implicitLogger("createPersonAction") )
  {
logger.info("Something to be logged");
with( auto cnx = implicitTransaction() )
{
   auto id =  cnx.execute(...);
   res.send(id); // Bad place... there is an oppened 
transaction here!!!

}
  };
```

... but remember than we need to manage "exceptions" dependant 
behaviours implicitly:  **with(** is not an option for AOP.



As you can see, this is not an "Object oriented dependency 
injection"... Each "withX" internally interacts with the context 
to find or create the resource and, additionally,  performs some 
functional extra proccessing (before, after and exception).


i.e.: withHttpResponse:
* if res.send is called: this is the data to be serialized as a 
result (status 202)
* if res.send is not called, then "404 not found" will be 
generated when delegate ends.
* if an exception is raised by the delegate, it will be 
transformed in an "standard" http error


As a ramarkable benefit:  it is really simple to wrap with 
mockups when testing


Problems?

* It is "runtime" generated/consumed without compilation time 
verification (i.e.: you can call createPersonAction without an 
HttpRequest in the context )... but this is a dependency 
injection assumed problem.


* You are in risk to move to "implicit context" too many things 
(remember that functions have parameters :-) )


It was only a possible use of "implicit context" :-)


Best regards





Re: second edition of Build Web Apps in Vibe.d by learning from a learner

2023-01-22 Thread Antonio via Digitalmars-d-announce

On Monday, 23 January 2023 at 01:48:11 UTC, Rey Valeza wrote:

Hi,

I just uploaded a second edition of the tutorial I uploaded on 
Github last year. Here is the link:

https://github.com/reyvaleza/vibed/blob/main/Build%20Web%20Apps%20in%20Vibed%20second%20edition.pdf

Thanks!


First look... nice job :-)


Re: Release D 2.100.0

2022-05-26 Thread Antonio via Digitalmars-d-announce

On Sunday, 15 May 2022 at 11:05:38 UTC, Martin Nowak wrote:

Glad to announce D 2.100.0, ♥ to the 41 contributors.

This release comes with improved C++ header gen, a new 
`@mustuse` attribute to enforce return-type error checking, a 
contract invariant version identifier, non-transitive inout 
returns, and many more improvements.


http://dlang.org/download.html
http://dlang.org/changelog/2.100.0.html

-Martin


An small great change:

https://dlang.org/changelog/2.100.0.html#std_typecons_nullable_range

Thanks a lot!!!