Re: "Little Scheme" and PL Design (Code Critique?)

2022-11-19 Thread Jack Pope via Digitalmars-d-learn
On Thursday, 17 November 2022 at 22:05:45 UTC, jwatson-CO-edu 
wrote:

[`Atom`](https://github.com/jwatson-CO-edu/SPARROW/blob/main/lil_schemer.d#L66) 
(unit of data), I throw it on the heap and never bother to delete it.  I 
understand that D does GC for me. I am interested in using either [timed 
GC](https://wiki.dlang.org/Memory_Management#Smooth_Operation) or a [free 
list](https://wiki.dlang.org/Memory_Management#Free_Lists) for finer control of 
GC.  Which is best for the application, do you think?



If you wish to automatically de-allocate the oldest atoms, one 
approach might be to put them in a ring buffer. Its size will 
affect the relative time needed for deleting and overwriting the 
oldest elements. You can hard code the size based on 
experimentation or allow ongoing automatic adjustment based on 
some formula.


I think there are some interesting ring buffer packages in the 
DUB registry.


Re: Generate a pointer to a method of a struct

2022-10-15 Thread Jack Pope via Digitalmars-d-learn

On Saturday, 15 October 2022 at 01:48:15 UTC, kdevel wrote:

$ dmd -unittest -main -run ini
ini.d(6): Error: non-constant expression `& bar`
ini.d(7): Error: non-constant expression `& bar`
```

Is this consistent?


I can attest to consistency using ldc. Each of the following 
prevent function address re-assignment:


  immutable string function() f = 
  const string function() f = 
  enum f = 

In contrast, as would be expected, the following has no such 
restriction:


  string function() f = 

Example:

  struct S {
string bar(){return "Hello";}
string foo(){return "Goodbye";}
  }

  void main() {
string function() f = 
writeln(f, " ", f());
f = 
writeln(f, " ", f());
  }




Re: private method callable from other module

2022-10-08 Thread Jack Pope via Digitalmars-d-learn
Altering the definition sequence in b.d to have the private 
version second has the desired result. Otherwise, when following 
private foo, it looks like public foo gets adopted as a public 
constructor. The same for classes.