Results 1 to 13 of 13

Thread: vb's most useless operator, turns out to be usefull after all

  1. #1

    Thread Starter
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Wink

    Some time ago, Kedaman posted a question about what possibly could be the use of the Imp operator.
    At that time, I couldn't find a use for it, but now it comes in very handy.

    I'm writing a program that needs to read the access rights someone has to a file. This person can also be a member of a group that has certain rights. Access rights can be either allowed or denied. The rights denied overrule the rights allowed. So if someone is member of a group with full control over a file, but also a member of a different group with delete rights denied, this person has all rights accept the delete rights.

    Now back to the IMP operator.

    The allowed and denied rights can be combined to the resulting access rights like this:

    Access rights = Not(Allowed Imp Denied)



    So thank you kedaman, for pointing me to that operator. I would have never thougth of it, if I didn't read your post.

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Not Wishing to Be Outdone, I've used it aswell. I'm using it in a Timer Class Module (like a normal timer but doesn't need placing on a form) to check wheather I need to start or stop an API Timer

    Code:
    Public Property Let Enabled(New_Enabled As Boolean)
    If Interval Then
    If Not (m_Interval Imp (New_Enabled Imp m_Enabled)) Then
    StartTimer
    ElseIf Not (m_Interval Imp (m_Enabled Imp New_Enabled)) Then
    StopTimer
    End If
    m_Enabled = New_Enabled
    End Property


    [Edited by Sam Finch on 07-02-2000 at 09:29 AM]

  3. #3
    Guest
    I would like to point something out. There is no "useless" operator in VB, otherwise they would not have put it in. So Kedaman, just because you did not find it useful, doesn't make it useless. Look at these two people for example.

  4. #4
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    It is fairly useless, it's exactly the same as
    Code:
    Not (A And (Not B))
    or
    Code:
    (Not A) Or B
    it just takes the brackets away.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Talking

    Hurray!

    Well I didn't post it but yeah I did also find out a way to use it in my latest application:
    Code:
    if (Winampdir=cmd.path) imp (cmd.path=playingfile) then exit sub
    But I guess Sam's right, but it maybe is faster to use one single operation...
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Lively Member
    Join Date
    Sep 1999
    Location
    u.s.a
    Posts
    127
    One could say taht all operators other than 2 are useless:
    Xor=((a) and (not b)) or ((not a ) and (b)).
    All operators can be represented by a combention of (not,and)
    or
    (not,or)
    I don't know what I'm trying to say....
    But I'm board shitless....
    Dan.

  7. #7
    Guest
    Someone in these fourms said that every computer program can be broken down into 3 commands. I believe that 1 of them was a GoTo.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Meg, i'm sure you know it's Sam
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Guest
    If I knew it was him, I would have mentioned it and asked him directly.

    But logically speaking, the other 2 would probably be a SetBit and a GetBit type of Command in which you can either set or get a bit.

  10. #10
    Guest

    Wink Just caren't get away from the GoTo statement

    This should get the University brigade out.

    Thanks for mentioning GoTo Meg, totally agree with you, a basic part of any language. If you need to speed up apps use GoTos, if you don't then avoid them like the plague.

    Does anyone know of a vb function that is totally useless???? Come on kedaman you must have another one. I only ask this to give bored members the chance to discover a hidden function, which they can then expierament with and give us back the results.

  11. #11
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Auckland, NZ
    Posts
    411

    Angry How about useless implementation instead?

    Speaking for myself only of course:

    I am an ex LISP (derivative) and a current Java / VB programmer. Although my experience in VB is limited, I must admit to getting tired of having to break down and otherwise good IF statement into two IF statements.

    In Java, I might have written
    if (not obj==null) and (obj.name=="something") {...

    or in SML (the LISP derivative which has an object layer),
    (if (and obj (= (get obj 'name) "something")) ...

    Both of these would be fine since if the object was not initialised (but was declared mind you), I'd have an early exit from the IF statement. In VB6 however, if I write:

    dim obj as MyObj
    ...
    if (not (obj is nothing)) and (obj.name="something") then ...

    then I get a runtime error because obj.name is evaluated regardless of whether the first clause is true or false.

    I am no compiler or interpreter writer.. I think of those tasks as wonderful black boxes, which suits me fine. I'm sure there is also a very good reason why VB HAS to act this way but I guess old habits are hard to break.

    For the sake of the thread (and I know this reply is a feeble attempt to maintain the gist of it...) I find the implementation of the IF statement in VB to be poor.

    But that's probably just my previous experience showing through

    Regards
    Paul Lewis

  12. #12
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Question What is imp and what is it used for?


    Hi,
    What is imp and what is it used for?
    Omar
    omarswan@freemail.org.mk
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  13. #13
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Imp mean implication operation

    (True expression) imp (false expression)

    is false

    other combinations are true

    And for bit comparations:
    0imp0=1
    0imp1=1
    1imp0=0
    1imp1=1

    Also as sam said it's the same thing as

    Not (A And (Not B))
    or
    (Not A) Or B

    So you wont need to use it! But it's a single operator and probably faster, if you have huge algoritms called frquently it might matter.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width