- "Death to C, ++" - 7 Updates
- Together, let us create something the world desperately needs - 3 Updates
- read-only, write-only and read-write memory mapped I/O - 1 Update
- Rudolph, the red-nosed reindeer - 1 Update
| David Brown <david.brown@hesbynett.no>: Aug 04 08:52AM +0200 On 03/08/17 21:22, Jerry Stuckle wrote: > Then please show how to define a pointer to an object in Java. And if > it is truly a pointer, show how you can use those pointers to do things > like step through an array by incrementing and decrementing them. I don't know Java at all, but I would not say that the ability to /change/ a pointer or use it to step through an array is an essential quality of a pointer. In C or C++, if you have: int x; int *p = &x; Then "p" is a pointer. You can use it to access the value of "x" through indirection. But you cannot increment it, decrement it, or step through an array by changing it. Well, you /can/ increment or decrement "p" - but dereferencing it would be undefined behaviour. |
| "Öö Tiib" <ootiib@hot.ee>: Aug 04 04:57AM -0700 On Friday, 4 August 2017 09:52:21 UTC+3, David Brown wrote: > I don't know Java at all, but I would not say that the ability to > /change/ a pointer or use it to step through an array is an essential > quality of a pointer. In Java all variables of Object type (or derived types) are pointers. Object someObj = null; // there are no objects pointed at by someObj someObj = new ArrayList<String>(); // now there is object pointed at by someObj someObj = SomeOtherClass(); // now some other object is pointed at by it someObj = null; // again nothing Since almost all things are Object in Java that leaves only variables of few fundamental types that are not pointers (and so can be used without that constant 'new' spam of Java): int a = '1'; char b = (char) a; |
| Jerry Stuckle <jstucklex@attglobal.net>: Aug 04 10:00AM -0400 On 8/4/2017 7:57 AM, Öö Tiib wrote: > used without that constant 'new' spam of Java): > int a = '1'; > char b = (char) a; The Java documentation calls these references. And that's what they are - they must always point at an object or null. You can't, for instance, set someObj an address. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
| Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Aug 04 04:36PM +0100 On 04/08/2017 15:00, Jerry Stuckle wrote: > The Java documentation calls these references. And that's what they are > - they must always point at an object or null. You can't, for instance, > set someObj an address. Of course you can set someObj to an address: the address of a new'd object. Just because pointers in Java aren't the same as pointers in C/C++ it doesn't mean they aren't pointers. It's java.lang.NullPointerException not java.lang.NullReferenceException. Java uses pointers; deal with it. /Flibble |
| Jerry Stuckle <jstucklex@attglobal.net>: Aug 04 04:04PM -0400 On 8/4/2017 11:36 AM, Mr Flibble wrote: > It's java.lang.NullPointerException not java.lang.NullReferenceException. > Java uses pointers; deal with it. > /Flibble Show where in the documentation it says Java uses pointers. And I'm talking about the doc - not an exception class. And I didn't say set it to the address of some object. I said set it to an address. For instance, the address of some I/O mapped port. Java doesn't even claim in their doc that they use pointers. They call them references because that's what they are. Deal with it. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
| Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Aug 04 10:26PM +0100 On 04/08/2017 21:04, Jerry Stuckle wrote: >> /Flibble > Show where in the documentation it says Java uses pointers. And I'm > talking about the doc - not an exception class. From section 4.3.1 of the Java Language Specification (v8): "The reference values (often just references) are pointers to these objects" So as you can see I am correct and you are wrong: Java uses pointers; deal with it. /Flibble |
| Manfred <invalid@invalid.add>: Aug 05 01:09AM +0200 On 08/04/2017 01:57 PM, Öö Tiib wrote: > // now some other object is pointed at by it > someObj = null; > // again nothing (Disclaimer: I am not a fan of Java, therefore I am no expert either, what I am going to say is based on the knowledge I have and what has been described in this thread.) The above can be considered pointers, in the sense that someObj represents a handle (I wouldn't say a memory address) to the object pointed to. But, in C and C++ terminology, a pointer is something different: it is a definite representation of a memory address, that can be accessed and manipulated (when needed) even in its numerical value - it is one of the distinct features that make C and C++ so "close to the metal", with respect to other languages, including Java. IOW Java can be said to have pointers (Mr Flibble gave a spec reference downthread), but they are not the same as C pointers - which is fine since C and Java are two distinct languages. I think this is a source of misunderstanding when talking cross-language. As for another comparison, C++ specifically adds the notion of "references". C++ references also represent (in practice, although in standardese it is more complicated than that) memory addresses to objects, but have a number of differences wrt pointers - two major differences that I find relevant here are: 1) The underlying memory address of a reference cannot be explicitly accessed, other than initializing it to an existing C++ object. 2) Such underlying memory address cannot be modified after initialization. In comparison to Java pointers/references, C++ references share the first property of the above, but not the second one, so strictly speaking Java references are not the same as C++ references either. (technically in Java also property 1 is different since there is no actual memory address, but since it is hidden in a C++ reference too, I think the similarity holds) As far as I understand, if I had to find a similarity with a C++ entity, a Java pointer/reference is probably closest to a C++ smart pointer (a CComPtr in old MFC terms, or a shared_pointer in more modern terms), with the constraint that the underlying address is never exposed - which is in fact consistent with the semantics of a smart pointer. One further consideration is that the distinction about C (and C++) pointers and Java pointers/references is not just a matter of exposing physical (well, in virtual address space) memory addresses for the fun of it, it is strictly related with the close coupling between the C memory model and the hardware implementation - which is a fundamental difference with Java. In C (and C++), when a struct (or an array) is defined in source code, in fact a physical memory layout is defined, and this makes it possible for memory addresses to be exposed and manipulated - via C pointers. Java does not do that, and this is one of the reasons for which you can create an OS in C (and in C++, although it is probably harder, and granted - with a fair bunch of asm), but you can't do it in Java. So, the way I see it, as far as terminology goes, Java may well have pointers, but they are not the same as C pointers. -- my 2 cents. |
| "Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Aug 04 07:49AM -0400 Please see this post and thread: https://groups.google.com/d/msg/comp.arch/F39_I0nipUg/4Th6IaCVAQAJ We can, together, create something to shake this world to its core, undoing centuries of hate and war. If we lift our lives to Jesus in love, and move forward in His teachings, with His goals, billions of lives will be affected, and this world will be changed forever. Join in. Add your voice to this chorus of man unto God. Use and direct your talents toward Him, and watch Him multiply your offer- ing out to multitudes. I urge you to move in love, today, toward Him, asking forgiveness, learning of Him, and doing for Him in this world. Your life will be rich, and your core man complete. It will bring you real peace and victory over that which has kept you down. Thank you, Rick C. Hodgin |
| Daniel <danielaparker@gmail.com>: Aug 04 12:46PM -0700 On Friday, August 4, 2017 at 7:50:00 AM UTC-4, Rick C. Hodgin wrote: > We can, together, create something to shake this world to its core, Tower of Babel redux! |
| "Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Aug 04 03:52PM -0400 On 8/4/2017 3:46 PM, Daniel wrote: > On Friday, August 4, 2017 at 7:50:00 AM UTC-4, Rick C. Hodgin wrote: >> We can, together, create something to shake this world to its core, > Tower of Babel redux! No. This is people where they are around the world in the disciplines their in doing the things they're doing and are already interested in, in changing their focus to be from worldly-serving-goals to those which are focused upon serving God. We purposefully look up to God, and we purposefully place Him ahead of the things we do, so that we are honoring Him with the fullness of our lives, including our labor hours, and our other hours. Thank you, Rick C. Hodgin |
| David Brown <david.brown@hesbynett.no>: Aug 04 08:47AM +0200 On 03/08/17 22:17, red floyd wrote: >> Or better still, uintptr_t, which is part of <stdint.h> in C and >> therefore part of C++. > Damn, *THAT'S* the one I was thinking of. That's what Usenet is for :-) |
| woodbrian77@gmail.com: Aug 03 10:48PM -0700 > FreeBSD, but hit a build problem with Boost. > Have I mentioned that the C++ Middleware Writer minimizes the > amount of code that you have to download/build/maintain/etc? I got past the build problems now and I got my version of the test working. The serialized size of the Record is 16,712 and the time is faster than cereal's time. I haven't done any profiling, but from looking at the code I think the call to resize below is kind of suspect. Resize sets the first n bits of the storage and then those same bits get reset. template<class R> Record::Record (::cmw::ReceiveBuffer<R>& buf){ int count[1]; count[0]=::cmw::Give<uint32_t>(buf); if(count[0]>0){ ids.resize(count[0]); buf.GiveBlock(&(*(ids.end()-count[0])),count[0]); } count[0]=::cmw::Give<uint32_t>(buf); strings.reserve(count[0]); for(;count[0]>0;--count[0]){ strings.emplace_back(buf.GiveString()); } } I've tried to rework that to use reserve, but my efforts have so far been unsuccessful. Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
| You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment