Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class operators Distinct from xHarbour #245

Open
Hovestar opened this issue Jun 7, 2021 · 1 comment
Open

Class operators Distinct from xHarbour #245

Hovestar opened this issue Jun 7, 2021 · 1 comment

Comments

@Hovestar
Copy link

Hovestar commented Jun 7, 2021

This is likely at most something to document in xhb-diff.txt, but xHarbour supports these 6 class operator overloads, that harbour does not:

 OpBitAnd
 OpBitOr
 OpBitShiftL
 OpBitShiftR
 OpBitXor
 OpForEach

Also the naming convention, which can be used to override an operator, is different for xHb's __OpContains and hb's (Interchangeable?) __OPINCLUDE and __OPINSTRING

Is the choice to not have the Bit operators and for each intentional?

As a note, since I haven't seen documentation for for each overloading in xhb this is the behavior:

class forEachRecnoObjectHolder
   data nTop
   method iterate operator "FOR EACH"
   method new constructor
endclass
method new(nTop)
   default nTop to 2
   ::nTop := nTop
return self
method iterate(nDepth,nStep)
   if nDepth == 1
      return self
   endif
   if nDepth > 2
      return nil
   endif
   if nStep > ::nTop
      break
   endif
return nStep

So calling for each n in forEachReconObjectHolder():new(3) will iterate through 1,2,3 and then exit. From the iterate call, it first calls with a depth, 1, where you then can return. If you return something iteratable it will iterate through it and then call with a nDepth of 2. If an object is returned it then will call with the same depth and a step, and the value will reflect exactly what you return, even if it's nil. To break the loop you need to call break at which point it will call with the next depth.

@alcz
Copy link
Contributor

alcz commented Nov 7, 2022

Harbour does not support bit operators overloads, because there is no support for those operators at all: https://github.com/harbour/core/blob/master/doc/xhb-diff.txt#L1055

I think this is mainly due to Clipper compatibility clashes. & is a macro operator.

There is a FOR EACH overloading example though:
https://github.com/harbour/core/blob/master/tests/foreach2.prg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants