[M3devel] STL algorithms? sort/unique?

Jay jay.krell at cornell.edu
Thu Oct 4 21:44:19 CEST 2012


Preprocessor does historically help -- makes inlining easier, including making  sizes visible. 


> And what is vector<int> if not pointer to some collection of pointers? 


No. Pointers to ints. The three pointers are start, just past end, just past end of allocation. Maybe easier to see as a pointer and 2 integers -- size and allocated size. But they are size_t and not 32bit int.


I'll present object code later...


 - Jay (briefly/pocket-sized-computer-aka-phone)

On Oct 4, 2012, at 11:30 AM, Dragiša Durić <dragisha at m3w.org> wrote:

> 
> 
> On Oct 4, 2012, at 3:59 AM, Jay K wrote:
> 
>> vector<int> is small, contains 3 pointers.
>> And one level of indirection for accessing the data.
>> printf("%d\n", vi[0]); has one level of indirection and will be inlined in any decent compiler.
> 
> Probably because preprocessor is in this equation?
> 
>> 
>> 
>> 
>> IntSeq.T is one pointer, and probably contains also approximately 3 pointers.
>> The Modula-3 has an extra level of indirection.
> 
> And what is vector<int> if not pointer to some collection of pointers? 
> 
> IntSeq is generic instantiation. Calls can be inlined by decent compiler. There lies probable reason for generics in Modula-3. So efficiency junkies can have their way :).
> 
> In my opinion, Moore's law combined with lives of my applications usually being longer than Moore's interval does all the extra speed magic I need.
> 
>> 
>> 
>> Not every function should be "virtual".
>> "object.method" is useful syntax for statically typed "object".
>> s.get(0) probably involves like 3 pointer derefences.
> 
> As opossed to C++'s two dereferences?
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20121004/6561f232/attachment-0002.html>


More information about the M3devel mailing list