Re: Include in standard library or build in?
- Posted by Matt Lewis <matthewwalkerlewis at ?mai?.com> Apr 28, 2008
- 610 views
CChris wrote: > > I can see a lot of proposals for additions in the standard library, specially > in the field of basic sequence manipulation. > > This will save typing, and spare the bugs that come with reinventing the > wheel. > Good. > > However, sometimes, it may be more efficient to implement some routines as > built-ins rather than in include files. One of the main reasons is that > checks of various kinds are performed twice or more, and data which is > available at run time is being queried by several pieces of code, for more > IL opcodes and no benefit. > > For very basic routines (I have head(), tail() and mid() in mind, and perhaps > a couple others), we should expertise whether moving them inside the > interpreter might not help the language by increasing efficiency, and in > some cases making code leaner instead of adding layers on top of one another. > > This could be a Rule #6: Check the compared benefits before choosing between > stdlib and backend (applies to basic functionality only). Yes, I fully agree with this. I'm doubtful that the head/tail type routines will have too much benefit (but would be happy to be proved wrong). I think a likely source for this sort of work is for removing elements from a sequence. Especially for big stuff, all we'd need to do is deref the elements going away, move the memory of the remaining, and update the padding and length info on the sequence. Matt