Coder Social home page Coder Social logo

Comments (7)

sikefield3 avatar sikefield3 commented on June 10, 2024

@linas I'm going to write the error message, ok?

from atomspace.

linas avatar linas commented on June 10, 2024

The code is misleading. The intent is that either the interval is specified, or it is not; if there are two (or more) intervals given, that is an error, and should be flagged as an error. In other words, extend() should never be called more than once.

Here's the misleading part:

  • make_interval() creates the invalid interval (MAX, 0)
  • extend() applied to the above and (L,U) always gives (L,U) as the result.
  • At the end, there are tests to look for the invalid interval, and to replace it by the default. (Because if it's invalid at the end, that means the interval was never set).

I suppose the above could have been written differently, in a less misleading fashion. Maybe with a bool flag not_been_set_yet instead of an invalid value. But that amounts to "the same thing".

The extend() function could be (should be??) re-written as:

extend(lhs) {
 if (rhs==invalid) return lhs;
if (lhs==invalid) return rhs;
throw ("Must not specify interval twice!");
}

Huh. Umm, except that foo==invalid is what TypeChoice::is_empty() does. So extend should be:

static inline GlobInterval extend(const GlobInterval& lhs,
                                  const GlobInterval& rhs)
{
   if (TypeChoice::is_empty(lhs)) return rhs;
   if (TypeChoice::is_empty(rhs)) return lhs;
   throw (Must not specify interval twice!); 
}

The current extend() implementation is left over from some earlier half-baked ideas. I think. The unit tests know for sure.

from atomspace.

sikefield3 avatar sikefield3 commented on June 10, 2024
static inline GlobInterval extend(const GlobInterval& lhs,
                                  const GlobInterval& rhs)
{
   if (TypeChoice::is_empty(lhs)) return rhs;
   if (TypeChoice::is_empty(rhs)) return lhs;
   throw (Must not specify interval twice!); 
}

The current extend() implementation is left over from some earlier half-baked ideas. I think. The unit tests know for sure.

The tests work with this change.

from atomspace.

sikefield3 avatar sikefield3 commented on June 10, 2024

The code is misleading. The intent is that either the interval is specified, or it is not; if there are two (or more) intervals given, that is an error, and should be flagged as an error. In other words, extend() should never be called more than once.

Here's the misleading part:

* `make_interval()` creates the invalid interval `(MAX, 0)`

So extend() is the method to create the interval one is interested in ?

GlobInterval TypeChoice::make_interval(const HandleSeq& ivl)
{

	long lb = std::lround(NumberNodeCast(ivl[0])->get_value());
	long ub = std::lround(NumberNodeCast(ivl[1])->get_value());

But couldn't make_interval() create a valid interval also, so that we don't need extend() ?

from atomspace.

linas avatar linas commented on June 10, 2024

Can I give a meta-level answer?

The primary goal is to have the Atomese expressions work well, and not be surprising or weird. Whatever C++ code accomplishes that is OK (I would find it acceptable), and whatever C++ code is the simplest and is the least misleading is best.

With that out of the way ... so ... how is the Atomese supposed to behave? Well, I look at the wiki, https://wiki.opencog.org/w/GlobNode and all of the examples have exactly one IntervalLink in them, and so they are never intersected or unioned or overlapped, so any extra logic for unions or intersections is not needed ... at least, for that use.

Next I click over to https://wiki.opencog.org/w/IntervalLink and it says even less. Except for one curious thing: it mentions "TimeInterval" I click thought and ... hmm disappointment.

To conclude: in this particular blob of code, where intervals are being used to indicate a range for glob matching, the current code is good enough. It's misleading ... but its not wrong. It could be made less misleading.

Now, there has been a different, distantly-related idea about "time intervals", and there has been much discussion about that over the years. If you are curious, I can repeat it; however, my basic take is that time intervals don't belong in the fundamental base AtomSpace. If someone wants to do them in some other repo, e.g. in https://github.com/opencog/spacetime, that's fine. I'd rather keep the base AtomSpace as small as reasonable.

from atomspace.

sikefield3 avatar sikefield3 commented on June 10, 2024

The primary goal is to have the Atomese expressions work well, and not be surprising or weird. Whatever C++ code accomplishes that is OK (I would find it acceptable), and whatever C++ code is the simplest and is the least misleading is best.

OK. I think I understand now.
Best I just close this off ...

from atomspace.

linas avatar linas commented on June 10, 2024

OK, thanks for the work! It's good work! I appreciate it! More!

from atomspace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.