David Larson wrote:
On Saturday, June 8, 2013 2:48:39 PM UTC-7, Bram Moolenaar wrote:
There are no options. Vim is written in C and I see no reason to
change. Perhaps, when Zimbu is "ready" I might consider rewriting some
pieces in Zimbu, but that's going to take several years during which no
bugs will be fixed and no new features will be added. For a similar
reason Elvis no longer exists...
Aack! Don't do that! We want VIM to stay alive. I personally am not willing to
see no advancement in VIM for several years just so that it can be ported to
Zimbu. (Perhaps that was your point...)
It seems somewhat safe to me if the file names were changed from .c to .cpp.
That would allow us to leverage basic libraries and simple OOP. We can steer
clear of the more esoteric and tricky features of the language.
I use some macros... (outofmem() can be removed; it checks if the
returned pointer is null, isses the failure message if so, and
terminates). These four macros presume that there are "nxt" and "prv"
pointers in the structure for linking.
#define double_link(structure,head,tail,fail_msg)
{ \
structure *newstr; \
newstr= (structure *)
malloc(sizeof(structure)); \
outofmem((void *)
newstr,"%s\n",fail_msg); \
if(tail) (tail)->nxt=
newstr; \
else head =
newstr; \
newstr->prv= tail; \
newstr->nxt= (structure *)
NULL; \
tail = newstr; \
}
#define delete_double_link(structure,str,head,tail)
{ \
structure *old=
str; \
if(old) { \
if(old->prv) old->prv->nxt=
old->nxt; \
else head =
old->nxt; \
if(old->nxt) old->nxt->prv=
old->prv; \
else tail =
old->prv; \
free((char *)
old); \
} \
}
#define only_double_link(structure,newstr,head,tail)
{ \
if(tail) (tail)->nxt=
newstr; \
else head =
newstr; \
newstr->prv= tail; \
newstr->nxt= (structure *)
NULL; \
tail = newstr; \
}
#define only_delete_double_link(structure,str,head,tail)
{ \
structure *old=
str; \
if(old) { \
if(old->prv) old->prv->nxt=
old->nxt; \
else head =
old->nxt; \
if(old->nxt) old->nxt->prv=
old->prv; \
else tail =
old->prv; \
} \
}
Typical use:
struct ABC_str {
double something;
struct ABC_str *nxt;
struct ABC_str *prv;
} *abchd= NULL, *abctl= NULL;
double_link(struct ABC_str, abchd,abctl,"failed while attempting to
double-link an ABC_str");
struct ABC_str *abc;
delete_double_link(struct ABC_str,abc,abchd,abctl);
Regards,
Chip Campbell
--
--
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.