On Jun 8, 2013 5:48 AM, "Marc Weber" <[email protected]> wrote: > > Well - I don't want to discuss the topic. > > I just want to know how to do basic stuff "the Vim way" efficiently. > > C++ is not perfect, and probably its easiy to get things wrong. > But at least it provides standard ways for standard tasks, such as > arrays/vectors/maps/hashes whatsoever. > > Eg buffer.c contains: > > > /* > * put new buffer at the end of the buffer list > */ > buf->b_next = NULL; > if (firstbuf == NULL) /* buffer list is empty */ > { > buf->b_prev = NULL; > firstbuf = buf; > } > else /* append new buffer at end of list */ > { > lastbuf->b_next = buf; > buf->b_prev = lastbuf; > } > lastbuf = buf; > > > which is not bad. But if you need the same feature again: a linked list > like whatsoveer structure, it looks like the standard way is to write > the same code again. Its taking programmers time and is more likely to > be wrong. > > I personally don't want to spend time on thinking about how to use > malloc, realoc or such for simple things like lists, maps, ... > > Thus is there a standard way, a preprocessor like library which gets the > job done? something like: > > define_list(vim_buffer); > > providing functions like > vim_buffer_list_new() > vim_buffer_list_add(...) > vim_buffer_list_remove(...) > > ? > > Does it make sense to port Vim to C++, just to use some very basic C++ > like features, such as vector, map and so on? > If not - can we document why? > > I know that Vim has a long history, but the future of Vim is likely to > be longer than its history. > > Does Vim run on any platforms only supporting C, not C++? > > Sorry for having to ask such a stupid question. Its about simple > features like "make vim populate quickfix in realtime, so that the 4sec > issue I talked about goes away". > > I expect that Vim's future will be longer than its (long) history was. > So its worth using simple improvements, too. > > If you think this question is nonsense, make me understand why. > > So which is the reason sticking to C only, and which is the reason not > introducing a template library for simple things like lists? > > If moving to C++ is not an option, but moving ot a tmeplate library is, > is there one you would recommend? > > I want to have a native implementation for vim-addon-async for example. > > Marc Weber
It is completely possible to define a linked list in one of the following ways: 1. Use fixed offset in structure: i.e. pointers to next and previous items are always the first one and list-manipulating functions just cast the buf_T* to linked_list_T* which is a structure that has nothing but next and previous pointers. This approach is extensively used in python for PyObject structures. 2. Your suggestion with preprocessor library. Note though that for portability reasons string concatenation should not be used in this library, limiting its usability. I guess moving to C++ can't be done for the same reasons. > -- > -- > You received this message from the "vim_dev" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php > > --- > You received this message because you are subscribed to the Google Groups "vim_dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
