Commit graph

5161 commits

Author SHA1 Message Date
63a49bccfd Library: define string conversion trait more precisely
It is pointless to include pointers....
A pointer to string is not "basically a string",
and char is handled explicitly anyway.
2017-12-04 03:53:36 +01:00
e379ad82c6 Library: typeof obsoleted by decltype
Replace the remaining usages of the GNU extension 'typeof()'
by the now-standard 'decltype()' operator
2017-12-04 03:53:36 +01:00
c65c5f812b Library: put the new type rebinding trait into general use
Obsoletes and replaces the ad-hoc written type rebindings from
iter-adapter and friends. The new scheme is more consistent and does
less magic, which necessitates an additional remove_pointer<IT> within
the iterator adaptors. Rationale is, "pointer" is treated now just as
a primitive type without additional magic or unwrapping, since it is
impossible to tell generically if the pointer or the pointee was
meant to be the "value"
2017-12-02 02:51:51 +01:00
847593f18b Investigation: resolve the mystery and fix the problem
Oh well.
This kept me busy a whole day long -- and someone less stubborn like myself
would probably supect a "compiler bug" or put the blame on the language C++

So to stress this point: the compiler behaved CORRECT

Just SFINAE is dangerous stuff: the metafunction I concieved yesterday requires
a complete type, yet, under rather specific circumstances, when instantiating
mutually dependent templates (in our case lib::diff::Record<GenNode> is a
recursive type), the distinction between "complete" and "incomplete"
becomes blurry, and depends on the processing order. Which gave the
misleading impression as if there was a side-effect where the presence
of one definition changes the meaning of another one used in the same
program. What happened in fact was just that the evaluation order was
changed, causing the metafunction to fail silently, thus picking
another specialisation.
2017-12-02 02:51:51 +01:00
2c53dc2e57 Investigation: failure to detect nested typedef
a metafunction to detect nested typedefs worked perfectly in the test setup,
but failed once included into application code.
2017-12-02 02:51:37 +01:00
b104508685 Library: extract type diagnostics test helpers 2017-12-01 03:51:54 +01:00
674201f5ea Library: finish new form of the type rebinding trait 2017-12-01 03:25:51 +01:00
1047f2f245 Library: decide on the overall shape of the type rebinding helper
- we do strip references
- we delegate to nested typedefs

Hoever, we do *not* treat const or pointers in any way special --
if the user want to strip or level these, he has to do so explicitly.
Initially it seemed like a good idea to do something clever here, but
on the long run, such "special treatment" is just good for surprises
2017-12-01 02:43:27 +01:00
dce09ebe0d Library: better use a dedicated detector metafunction
...and check for presence of *all three* standard type bindings

 - value_type
 - reference
 - pointer
2017-11-30 23:41:12 +01:00
6bb288bf20 Library: search for a way to rebind to nested definitions
...automatically whenever those are present.
Up to now, we hat that as base case, which limited usage to those cases
where we already know such nested definitions are actually present
2017-11-30 23:28:00 +01:00
d73b0b05b2 Library: attempt to get more explicit type diagnostics
...including the various reference and pointer adornments;
typeid() unfortunately strips those, so we'll have to add them manually
2017-11-30 23:23:54 +01:00
60301f7523 Library: need an augmented version of the iterator type rebinding helper
yet another quick-n-dirty hack turned into an useful everyday helper...

but at least I need it to be symmetric in and universally applyable
2017-11-30 21:02:36 +01:00
a3a64147c1 TreeExplorer: implementation draft for the transform-operation
attempt to re-use the same traits as much as possible

NOTE: new code not passing compiler yet, but refactored old code
      does, and still passes unit test
2017-11-30 03:52:32 +01:00
09a263431c TreeExplorer: note further functionality to supplement
- add a filter (should be low hanging fruit)
- wrap the result as IterSource
2017-11-28 03:53:38 +01:00
5b86b660ae TreeExplorer: draft functionality of transform-operation 2017-11-28 03:53:09 +01:00
884af619a1 Library: change IterStateWrapper to delayed start-of-evaluation
this is a subtle change which, given all interfaces were used in a logically
consistent way, should not cause any observable change to the yielded elements.
But it changes runtime behaviour, insofar now the evalutaion is initiated
lazily, when first requesting a result type. Prior to this change, the
constructor immediately issued a call to the yield() extension point,
which presumably has the side-effect of preparing the core and initiating
any embedded evaluation, in order to get at the first result; it might
even detect an empty state.

Given the fact that all access operations on the iterator front-end perform
an empty check (and possibly throw at that point), this call is redundant.
2017-11-27 05:56:03 +01:00
134821ca15 DOC: document some of the language limitations highlighted by this research 2017-11-27 05:39:47 +01:00
d8f7a22123 TreeExplorer: cover all the remaining cases supported for the expansion functor 2017-11-27 05:07:06 +01:00
86856390e1 TreeExplorer: cover expansion using a different result type
here using a lambda with side-effect and returning a reference to
a STL collection with the children, which is managed elsewhere.
2017-11-27 05:07:06 +01:00
77c3226948 TreeExplorer: identify yet another subtle type inference problem
surprising behaviour encountered while covering more cases

...obviously the return type of ExpandFunctor::operator()
was inferred as value, even while the invoked functor, from which
this type was deduced, clearly returns a reference.

Solution is simple not to rely on inference, moreover since we know
the exact type in the enclosing scope, thanks to the refactoring which
made this ExpandFunctor a nested class

NOTE:
as it turned out, this is not a compiler bug,
but works as defined by the language:
on return type inference, the detected type is decayed,
which usually helps to prevent returning a reference to a temporary
2017-11-27 05:02:57 +01:00
6667a51a61 TreeExplorer: cover another use case expand( Val -> iter<Val> )
...which uncovered an error in the test fixture
plus helped to spot the spurious copy when passing the argument to the expand functor

And my GDB crashed when loading the executable, YAY!
so we'll need to coment out some code from now on,
until we're able to switch to a more recent toolchain  (#1118)
2017-11-26 22:35:43 +01:00
89005dbeb7 TreeExplorer: fix spurious copy of iterator (argument) on functor invocation
...since our iterators *always* yield a reference to the exposed element,
we can *always* get that referency into the nested yield to obtain the value
2017-11-26 22:29:51 +01:00
9e96ea8323 TreeExplorer: documentation of technicalities 2017-11-25 03:56:44 +01:00
76a11b3730 TreeExplorer: rename and refactor for readability
...while this implementation works now, it is still very complex and intricate.
I am still doubtful this is a good approach, but well, we need to try that route....
2017-11-25 03:54:41 +01:00
bb948bff34 TreeExplorer: working solution to accept generic lambda
but possible only for the iterator -> iterator case

Since we can not "probe" a generic lambda, we get only one shot:
we can try to bind it into a std::function with the assumed signature
2017-11-25 02:16:21 +01:00
4098e2024d TreeExplorer: Sketch how it might be possible to accept generic lambdas
...based on the research from yesterday
2017-11-24 23:48:56 +01:00
3614085ff7 Library: improve the function-signature detector to work as guard with enable_if
This is a consequence of the experiments with generic lambdas.
Up to now, lib::meta::_Fun<F> failed with a compilation error
when passing the decltype of such a generic lambda.

The new behaviour is to pick the empty specialisation (std::false_type) in such cases,
allowing to guard explicit specialisations when no suitable functor type
is passed
2017-11-24 23:48:56 +01:00
8bdd9e7d66 Research: build "anything function-like" trait
...with the sole exception that such a trait can not detect
a templated or overloaded function call operator
2017-11-24 23:48:56 +01:00
2533565f83 Research: probing a generic lambda is not possible
...since all those metaprogramming techniques rely on SFINAE,
but *instantiating* a template means to compile it, which is more
than just substituate a type into the signature

If forming the signature fails -> SFINAE, try next one
If instantiating a template fails -> compile error, abort
2017-11-24 23:48:56 +01:00
01937f9736 Research: possiblity to detect a generic Lambda? 2017-11-24 23:48:56 +01:00
18553f22b2 TreeExplorer: cover both variants of functor signature by unit test (PASS) 2017-11-23 03:29:26 +01:00
c5311a116a TreeExplorer: concept how to generalise the expansion functor
Basically we want to support two distinct cases, just by slightly adapting
the invocation of the expansion functor:

Case-1: classical monadic flatMap:
        the Functor accepts a value yielded by the source iterator
        and builds a new "expaneded" iterator

Case-2: manipulation of opaque implementation state
        the Functor knows internal details of the source iterator
        and thus takes the source iterator as such as argument,
        performs some manipulation and then builds a new sub-iterator

A soulution to reconcile those two distinct cases can be built
with the help of a generic lambda
2017-11-23 03:06:02 +01:00
f10e66e4ae TreeExplorer: design a solution to handle expansion of children
this solution makes me feel somewhat queasy..
stacking several adaptors and wrappers and traits on top of each other.

Well, it type checks and passes the test, so let's trust functional programming
2017-11-20 01:03:44 +01:00
d10c5a4f77 TreeExplorer: draft the core (explore) operation
The plan is to use a monad-like scheme, but allow for a lot of leeway
with respect to the src and value types of the expand functor.
A key idea is to allow for a *different* state core than used in the source
2017-11-19 20:36:19 +01:00
cbb35d7161 TreeExplorer: add shortcut to adapt STL container automatically
...selecting the iterator or const iterator as apropriate
2017-11-19 17:35:00 +01:00
fd3d6fb60e TreeExplorer: first testcase, build either from Lumiera-Iterator or use StateCore
TODO: also wrap any suitable STL iterable.
we need a one-shot solution here
2017-11-19 02:28:48 +01:00
fe3feee67a Library: metafunction to detect support for a specific extension point
such a detector function can be used to enable some template specialisation
based on the fact that a target type exposes the desired extension point
2017-11-19 01:43:19 +01:00
8f865183e3 Research: how to build a meta predicate to perform this detection 2017-11-19 00:35:38 +01:00
2345d76138 Research: how to detect that a type in question exposes a free function extension point
The key trick is to form an expression with the free function, using a declval of the type to probe.
What is somewhat tricky is the fact that functions can be void, so we need just to pick up
the type and use it in another type expression
2017-11-19 00:35:38 +01:00
9460f79039 WIP: draft how to figure out the kind of iterator
...but does not work as intended:
 * just forming an IterStateWrapper does not trigger SFINAE cleanly in all cases
 * IterStateWrapper can be formed, even when some of the extension points are missing;
   this will be uncovered only later, when actually using one of the operations

but beyond that, the basic type selection logic can work this way
2017-11-18 19:28:57 +01:00
a7bdc05091 WIP: draft first testcase
...just wrapping various kinds of iterators
2017-11-18 18:40:30 +01:00
c3b04af76f TreeExplorer: decide upon the steps towards implementation
Here, the tricky question remains, how to relate this evalutaion scheme
to the well known monadic handling of collections and iterators.

It seems, we can not yet decide upon that question, rather we should
first try to build a concrete implementation of the envisioned algorithm
and then reconsider the question later, to what extent this is "monadic"
2017-11-18 03:00:59 +01:00
782b4f949f TreeExplorer: extended analysis regarding tree expanding and backtracking computation (#1117)
This can be seen as a side track, but the hope is
by relying on some kind of monadic evaluation pattern, we'll be
able to to reconcile the IterExplorer draft from 2012 with the requirement
to keep the implementation of "tree position" entirely opaque.

The latter is mandatory in the use case here, since we must not intermingle
the algorithm to resolve UI-coordinates in any way with the code actually
navigating and accessing GTK widgets. Thus, we're forced to build some kind
of abstraction barrier, and this turns out to be surprisingly difficult.
2017-11-17 21:43:50 +01:00
ca35891c41 Navigator: implement the mutation operations defined thus far
...so the only thing not yet implemented is the actual path resolution algorithm
2017-10-30 03:10:51 +01:00
e035dbc54a UI-Coordinates: support for truncating a given spec
...implemented within the builder.
Will shorten and discard extraneous storage,
but not expand and allocate new one
2017-10-30 02:59:56 +01:00
5530bbede8 Navigator: decide upon the fine points of meaning
anchorage vs. coverage
partial vs total
possible anchorage
possible coverage
2017-10-30 01:47:29 +01:00
4b6b4ad708 LocationQuery: now able to handle perspective info properly
...which was deliberately represented in an asymmetric way, to verify the
design's ability to cope with such implementation intricacies. So basically
we have to kick in at LEVEL == 1 and access the implementation differently.

This exercise just shows again, that treating tree structures recursively
is the way to go, and we should do similar when coding up the query-API
for the real GTK toolkit based window elements...
2017-10-29 16:00:08 +01:00
750b124f88 Library: complement the pseudo-iterator by a IterSource front-end 2017-10-29 15:31:34 +01:00
0682e449a3 Library: a pseudo-iterator to yield just a single value
...which can be helpful when a function usually returns a somewhat dressed-up iterator,
but needs to return a specific fixed value under some circumstances
2017-10-29 14:51:51 +01:00
7e241d9a11 Library: a little bit of modernising and overhaul
- fix some warnings due to uninitialised members
  (no real problem, since these members get assigned anyway)
- use a lambda as example function right in the test
- use move initialisation and the new util::join
2017-10-29 13:22:25 +01:00