Irc-Unix.net

Главная | Actual Topics | Обратная связь | Guest Book | В избранное | Сделать домашней
Категории
 System & Utilities
 Unix News
 OS Emulator
 Developing
 Learning/Education
 Games
 Humour
Каталог статей
Все статьи

Antispam
Статьи
Биллу Гейтсу тоже предлагают избавиться ...
Вымогательство в борьбе со спамом
Календарь

December, 2017
ПнВтСрЧтПтСбВс
123
45678910
11121314151617
18192021222324
25262728293031
Опросы
Какой из этих ОС Вы отдаете большее предпочтение?

QNX
FreeBSD
Linux(any)
Solaris
Mac OS
Windows XP
Windows 2003
Что такое ОС? :)


Результаты
Другие опросы

Всего голосов: 325
Комментарии: 0
Ссылки

Архив Новостей
 December 2017 (4)
 November 2017 (15)
 October 2017 (19)
 September 2017 (18)
 August 2017 (13)
 February 2017 (14)
 January 2017 (19)
 December 2016 (16)
 November 2016 (16)
 October 2016 (21)
 September 2016 (18)
 August 2016 (16)
 July 2016 (16)
 June 2016 (20)
 May 2016 (18)
 April 2016 (15)
 March 2016 (22)
 February 2016 (17)
 January 2016 (15)
 December 2015 (15)
 November 2015 (22)
 October 2015 (20)
 September 2015 (17)
 August 2015 (25)
 July 2015 (20)
 June 2015 (23)
 May 2015 (21)
 April 2015 (17)
 March 2015 (19)
 February 2015 (9)
 January 2015 (23)
 December 2014 (9)
 November 2014 (13)
 October 2014 (12)
 September 2014 (18)
 August 2014 (20)
 July 2014 (10)
 June 2014 (12)
 May 2014 (12)
 April 2014 (10)
 March 2014 (22)
 February 2014 (10)
 January 2014 (8)
 December 2013 (26)
 November 2013 (53)
 October 2013 (40)
 September 2013 (48)
 August 2013 (63)
 July 2013 (56)
 June 2013 (52)
 May 2013 (49)
 April 2013 (67)
 March 2013 (74)
 February 2013 (63)
 January 2013 (62)
 December 2012 (62)
 November 2012 (66)
 October 2012 (68)
 September 2012 (48)
 August 2012 (75)
 July 2012 (60)
 June 2012 (71)
 May 2012 (69)
 April 2012 (85)
 March 2012 (86)
 February 2012 (90)
 January 2012 (81)
 December 2011 (103)
 November 2011 (118)
 October 2011 (74)
 September 2011 (2)
 June 2011 (110)
 May 2011 (118)
 April 2011 (111)
 March 2011 (112)
 February 2011 (101)
 January 2011 (119)
 December 2010 (117)
 November 2010 (118)
 October 2010 (131)
 September 2010 (117)
 August 2010 (226)
 July 2010 (351)
 June 2010 (305)
 May 2010 (319)
 April 2010 (343)
 March 2010 (329)
 February 2010 (311)
 January 2010 (312)
 December 2009 (266)
 November 2009 (156)
 July 2009 (101)
 June 2009 (279)
 May 2009 (365)
 April 2009 (348)
 March 2009 (347)
 February 2009 (323)
 January 2009 (318)
 December 2008 (237)
 November 2008 (155)
 October 2008 (334)
 September 2008 (310)
 August 2008 (343)
 July 2008 (362)
 June 2008 (322)
 May 2008 (591)
 April 2008 (1276)
 March 2008 (1658)
 February 2008 (250)
 January 2008 (6)
 November 2007 (1)
 September 2007 (1)
 June 2007 (1)
 May 2007 (1)
 March 2007 (1)
 January 2007 (2)
 December 2006 (1)
 October 2006 (2)
 September 2006 (1)
 August 2006 (2)

VIM: “Hiding” C++11 lambdas

System & Utilities

One of my favourite C++11 features are lambdas.

The syntax is a bit cumbersome, but it was the best approach the committee could take without creating a new sub-language. Every part of the syntax has a reason for why it exists.

But, it still is a bit ugly, and can influence readability of the surrounding code quite a bit.

Lambdas in C++11

The thing that annoys me the most is the lambda head – the capture block and the arguments it takes. Those are very important when writing the code, but not (that much) when reading it.

My solution for this? The conceal feature of Vim.

C++11 Lambdas concealed

The good thing about lambdas is that they are (meant to) be used as local anonymous functions. That means that, while reading other parts of the code, you don’t actually need to know what the lambda is capturing, nor which are its arguments. So, it doesn’t hurt to hide them, right?

Naturally, when you want to edit the lambda head, Vim shows the actual contents of line, and not just some strange Greek symbol. :)

This also lowers the desire to use the potentially problematic [&] and [=] as the capture block, instead of explicitly capturing the variables that you need.

Edit: The code to achieve this:

.vimrc:
set conceallevel=1
.vim/after/syntax/cpp/cpp.vim
syn match cpp11_lambda \"[[a-zA-Z0-9&= ,]*] *(.*)( *{)@=\" conceal cchar=λ
syn match cpp11_lambda \"[[a-zA-Z0-9&= ,]*]( *{)@=\" conceal cchar=λ




  


Разместил: Planet KDE | Дата: 11.04.2014 | Прочитано: 458 | Раздел: System & Utilities   

Рейтинг статьи

Средняя оценка: 0.00/0Средняя оценка: 0Всего голосов:0

Отлично
Хорошо Нормально Пойдёт Плохо


Смотрите также связанные темы

27.04.2010 VMforce and VMware’s “Open PaaS” Strategy
VMforce and VMware’s “Open PaaS” Strategy Posted by Steve Herrod Chief Technology Officer It was almost 9 months ago that we acquired SpringSource, bringing VMware one of the most popular Java development frameworks, stewardship of the Apache Tomcat, Apache HTTP Server, Hyperic, Groovy and Grails open source communities, and a group of talented engineers focused on the efficient development of applications for the cloud-computing era. We’ve recently augmented this team with the acquisition of Rabbit Technologies, the company behind the popular open source cloud messaging technol...
04.12.2013 О второй операционной системе в каждом мобильном телефоне
Опубликован русскоязычный перевод статьи «The second operating system hiding in every mobile phone», в которой освещен вопрос безопасности современных средств связи, рассмотрены сценарии атаки, приведена оценка качества встроенного ПО.>>> Русскоязычная версия   безопасность
Нет комментариев. Почему бы Вам не оставить свой?
Вы не можете отправить комментарий анонимно, пожалуйста зарегистрируйтесь.
Google Search
Google

Web irc-unix.net

Топ Новостей
1: KDE Community announces fully open source Plasma Mobile
Hot NEWS!
Просмотров - 589


2: KWallet5 can be auto-unlocked during login again
Просмотров - 526

3: Interview with Laura
Просмотров - 510

4: Use ownCloud provided Packages, then VM, then Zip, no distro packages.
Просмотров - 497

5: Plasma Components on Android: Accelerating Subsurface Mobile Development
Просмотров - 484

6: VMware Workstation 11 and kwin - hangs and hiccups (solved?)
Просмотров - 461

7: Plasma 5 Powers KaOS Productivity
Просмотров - 456

8: KWrite on Mac – Application Bundle
Просмотров - 451

9: New Year Calligra Words Sprint
Просмотров - 428

10: FOSDEM Desktops DevRoom 2016 Call for Participation
Просмотров - 426

11: digiKam 5.0.0-beta2 is released
Просмотров - 418

12: Interview with Pierre Geier
Просмотров - 411

13: back in the habit
Просмотров - 403

14: Amarok is slowly catching up
Просмотров - 391

15: My experience at Randa Meetings, 2015
Просмотров - 384

Google 120X240
Ссылки

Главная | Actual Topics | Статьи | Обратная связь | Guest Book
Генерация: 0.865 сек. и 12 запросов к базе данных за 0.831 сек.
Powered by SLAED CMS © 2005-2007 SLAED. All rights reserved.