about pointer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Biber

    #16
    Re: about pointer

    venkatesh wrote:[color=blue]
    > hai,
    > any can tell what is the advantge of using pointers?any increase in
    > speed or execution time?
    > if you know please tell what are the real time applications of data
    > structure?[/color]

    There are very few data structures that do not involve the use of
    pointers. Almost all useful C programs use some values of pointer type.
    The C language is designed around pointers. Without them, it is severely
    crippled.

    Does that answer your question? If not, give a more specific question!

    --
    Simon.

    Comment

    • John Bode

      #17
      Re: about pointer


      carlos@colorado .edu wrote:[color=blue]
      > Are pointers necessary beyond system programming? There
      > are languages without them, e.g the Algol descendants and
      > some C supersets.[/color]

      Anything involving memory management involves pointers of some form,
      and memory management comes into play all over the place, not just in
      systems programming.

      Regardless of whether they're exposed with special syntax/semantics as
      in C and C++ or hidden behind reference types as in Java, pointers are
      necessary for a wide variety of operations. A host of basic data
      structures such as trees and lists rely on the ability to reference
      arbitrary memory locations.

      Comment

      • Walter Roberson

        #18
        Re: about pointer

        In article <437b6ce5$0$110 79$e4fe514c@new s.xs4all.nl>,
        Skarmander <invalid@dontma ilme.com> wrote:[color=blue]
        >carlos@colorad o.edu wrote:[color=green]
        >> Are pointers necessary beyond system programming? There
        >> are languages without them, e.g the Algol descendants and
        >> some C supersets.[/color][/color]
        [color=blue]
        >Many imperative languages that do not have pointers have references --
        >that includes Algol 68.[/color]

        In "A Practical Guide to Algol 68" (Frank G. Pagan, 1976),
        the section that discusses 'ref' has the heading

        6.2.1 Pointers and Casts

        and the term "pointer" is used throughout that section.
        --
        I was very young in those days, but I was also rather dim.
        -- Christopher Priest

        Comment

        • Skarmander

          #19
          Re: about pointer

          Walter Roberson wrote:[color=blue]
          > In article <437b6ce5$0$110 79$e4fe514c@new s.xs4all.nl>,
          > Skarmander <invalid@dontma ilme.com> wrote:
          >[color=green]
          >>carlos@colora do.edu wrote:
          >>[color=darkred]
          >>>Are pointers necessary beyond system programming? There
          >>>are languages without them, e.g the Algol descendants and
          >>>some C supersets.[/color][/color]
          >
          >[color=green]
          >>Many imperative languages that do not have pointers have references --
          >>that includes Algol 68.[/color]
          >
          >
          > In "A Practical Guide to Algol 68" (Frank G. Pagan, 1976),
          > the section that discusses 'ref' has the heading
          >
          > 6.2.1 Pointers and Casts
          >
          > and the term "pointer" is used throughout that section.[/color]

          But they *are* references, not pointers, in modern parlance, even if
          back in 1976 this distinction was not made. Correct me if I'm wrong, but
          I do not believe Algol 68 has pointers in the C sense -- things you can
          point to arbitrary memory locations, perform arithmetic on, cast to and
          from all sorts of types, and allowing dereferencing only on the
          programmer's responsibility that it makes sense at all.

          S.

          Comment

          • Skarmander

            #20
            Re: about pointer

            John Bode wrote:[color=blue]
            > carlos@colorado .edu wrote:
            >[color=green]
            >>Are pointers necessary beyond system programming? There
            >>are languages without them, e.g the Algol descendants and
            >>some C supersets.[/color]
            >
            >
            > Anything involving memory management involves pointers of some form,
            > and memory management comes into play all over the place, not just in
            > systems programming.
            >
            > Regardless of whether they're exposed with special syntax/semantics as
            > in C and C++ or hidden behind reference types as in Java, pointers are
            > necessary for a wide variety of operations. A host of basic data
            > structures such as trees and lists rely on the ability to reference
            > arbitrary memory locations.
            >[/color]
            I feel a slight reformulation is necessary. Basic data structures rely
            on the ability to reference *objects*, not arbitrary memory locations.
            (Some advanced data structures may take advantage of various tricks to
            save time and space by going low-level on the bits that make up objects,
            but these are not general or portable.)

            Looking at references as "hiding" pointers is a good way to understand
            it coming from C, but it's unnecessary if you're working in the
            languages themselves -- references are just references. They reference
            objects and different references can reference the same object, so that
            operations affect the object as seen from all references to it. That's
            about all you need to know; you don't want to think in terms of memory
            locations unless you're implementing the language.

            S.

            Comment

            • Keith Thompson

              #21
              Re: about pointer

              Skarmander <invalid@dontma ilme.com> writes:[color=blue]
              > Walter Roberson wrote:[color=green]
              >> In article <437b6ce5$0$110 79$e4fe514c@new s.xs4all.nl>,
              >> Skarmander <invalid@dontma ilme.com> wrote:[color=darkred]
              >>>carlos@color ado.edu wrote:
              >>>
              >>>>Are pointers necessary beyond system programming? There
              >>>>are languages without them, e.g the Algol descendants and
              >>>>some C supersets.[/color]
              >>[color=darkred]
              >>> Many imperative languages that do not have pointers have references --
              >>>that includes Algol 68.[/color]
              >> In "A Practical Guide to Algol 68" (Frank G. Pagan, 1976),
              >> the section that discusses 'ref' has the heading
              >> 6.2.1 Pointers and Casts
              >> and the term "pointer" is used throughout that section.[/color]
              >
              > But they *are* references, not pointers, in modern parlance, even if
              > back in 1976 this distinction was not made. Correct me if I'm wrong,
              > but I do not believe Algol 68 has pointers in the C sense -- things
              > you can point to arbitrary memory locations, perform arithmetic on,
              > cast to and from all sorts of types, and allowing dereferencing only
              > on the programmer's responsibility that it makes sense at all.[/color]

              I think this is about to devolve into a debate over the meaning of the
              term "pointer". That's sensible in the context of a single language,
              but it's going to cause confusion if you try to define the term across
              languages that have different semantics for similarly-named
              constructs. Each language has its own terminology.

              (Personally, I'd say that both Algol 68 and C have pointers; C's
              pointers are just particularly undisciplined.)

              --
              Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
              San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
              We must do something. This is something. Therefore, we must do this.

              Comment

              • Skarmander

                #22
                Re: about pointer

                Keith Thompson wrote:
                [references and pointers][color=blue]
                > I think this is about to devolve into a debate over the meaning of the
                > term "pointer". That's sensible in the context of a single language,
                > but it's going to cause confusion if you try to define the term across
                > languages that have different semantics for similarly-named
                > constructs. Each language has its own terminology.
                >[/color]
                Oh, poppycock. Languages agree on the general terms that allow effective
                comparison, like function, procedure, subprogram, subroutine, routine... :-)
                [color=blue]
                > (Personally, I'd say that both Algol 68 and C have pointers; C's
                > pointers are just particularly undisciplined.)
                >[/color]
                I have no problem calling references "discipline d pointers", and in my
                mind the distinction makes sense across languages, but it wasn't my
                intent to start a definition war.

                S.

                Comment

                • Amar Prakash Tripaithi

                  #23
                  Re: about pointer

                  Dear venktash,
                  Beside dynamic memory allocation, pointers increases the
                  execution time of a program. You can itself test it by writing programs
                  such as Fermat and Pythgoras in C and then in java or else.

                  Comment

                  • Keith Thompson

                    #24
                    Re: about pointer

                    "Amar Prakash Tripaithi" <tripathi.satya @gmail.com> writes:[color=blue]
                    > Dear venktash,
                    > Beside dynamic memory allocation, pointers increases the
                    > execution time of a program. You can itself test it by writing programs
                    > such as Fermat and Pythgoras in C and then in java or else.[/color]

                    That doesn't make any sense. A given algorithm implemented using
                    pointers *might* be slower than the same algorithm implemented without
                    pointers, but writing two different implementations is non-trivial,
                    and any performance difference caused by the use of pointers is likely
                    to be swamped by other differences. Comparing equivalent programs in
                    C and Java certainly isn't going to tell you anything about the
                    performance impact of pointers.

                    Use pointers when it makes sense to do so, and not when it doesn't.
                    Get the program working before you worry about micro-optimization.

                    --
                    Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
                    We must do something. This is something. Therefore, we must do this.

                    Comment

                    • Tim Rentsch

                      #25
                      Re: about pointer

                      Ben Pfaff <blp@cs.stanfor d.edu> writes:
                      [color=blue]
                      > I'm not sure what you mean by "the Algol descendants" here. C is
                      > an Algol descendant. [...][/color]

                      I would say C is more Algol-influenced than an Algol descendant.
                      Algol has nested functions, which C emphatically does not. Obviously
                      there are other differences, but this difference seems essential
                      rather than incidental.

                      Comment

                      Working...