Главная страница Google Groups
Справка | Вход
Сообщение из обсуждения formal review of Switch library ends tomorrow (Wednesday, January 9th) - reviews needed
Сообщение будет отправлено в группу Usenet. Когда Вы отправляете сообщения в такие группы, Ваш адрес электронной почты публикуется в Интернете.
Ваш ответ не был отправлен.
Сообщение отправлено успешно.
Tobias Schwinger  
Просмотреть профиль
 Дополнительные параметры 10 янв, 21:41
Автор: Tobias Schwinger <tschwin...@isonews2.com>
Дата: Thu, 10 Jan 2008 20:41:55 +0100
Местное время: Чт. 10 янв 2008 21:41
Тема: Re: [Boost-users] formal review of Switch library ends tomorrow (Wednesday, January 9th) - reviews needed
It makes sense to answer this one in LIFO order.

Joel de Guzman wrote:

 >
 >      template <typename Cases>
 >      void foo(Cases cases) {
 >          switch_<void>(n)(cases);
 >      }

Aha!

Then 'switch_<void>(n)' is a fused function and 'cases' a sequence of
cases (whether implemented with Fusion or not)...

 > The number of cases *can* vary at compile time. I have a guess that
 > we're talking past each other.

Yes, obviously -- I think because of a pair of parentheses. This code

     switch_<result>(n)
     ((
         // ... hand-written cases, note (( ))
     ));

would've told me more easily what you're up to :-).

 >>> For the purpose of clarification, let me call the original
 >>> interface A and my proposal B.
 >>>
 >>> Again:
 >>>
 >>> * Transforming A to B requires minimal amount of coding. The smarts
 >>>    is already in the PP code. The cost is cheap.
 >> The cost is cheap and the effect is destructive :-).
 >
 > Why is it destructive?

We lose the index and the chance to easily use a single function for all
cases.

 > You must be seeing a use-case that I don't.

Yes, see below.

[...]

 >
 > To be honest, I really don't see your point. I still don't see why
 > you'd want to build A on top of B.
 >

1. As a thought experiment to figure out which of the two variants is
the more basic one, and

2. for parameterizing a single function with compile time information
looked up by index (it's quite common and -as you can probably guess-
the index can be very handy inside the metaprogram).

Now that I have figured out that your interface accepts sequences, we
can actually express the transforms between the two:

     A ---> B: function := L(I): functions[I]()
     B ---> A: transform(cases, L(I): make_pair<I>(bind(function,I())))

     // Notation:
     // =========
     // uppercase - types
     // lowercase - objects
     // L(args):  - lambda composition

I don't expect us to a reach consensus, but hopefully we do understand
each other's points now.

Regards,
Tobias

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.

Создайте группу - Группы Google - Главная страница Google - Условия предоставления услуг - Политика конфиденциальности
©2008 Google