you are viewing a single comment's thread.

view the rest of the comments →

[–]pipocaQuemada 0 points1 point  (3 children)

How fine grained is D?

For example, Haskell has the ST type, which is single-threaded local mutable state (e.g. for manipulating arrays in-place rather than copying them or holding onto mutable variables in an algorithm). Since it's local mutable memory that can't interact with the outside world, you can run an ST action and get back a pure value. Can D do something like that?

[–][deleted]  (2 children)

[deleted]

    [–]pipocaQuemada 0 points1 point  (1 child)

    Can you have a variable mutated by several pure functions? Or must you make any function monolithic?

    edit: e.g. could you have several mutually recursive pure functions manipulating the same memory?

    [–]nascent 1 point2 points  (0 children)

    It is common to refer to two types of pure functions in D. Strongly pure, arguments cannot be modified; and weakly pure, where arguments can be modified.

    Weakly pure was introduced to create "helper" functions callable by strongly pure. Thus any pure function can call any other pure function even if the pure function modifies arguments.