pre or post condition

13 views
Skip to first unread message

jacques silberstein

unread,
Jan 12, 2026, 11:50:52 AM (8 days ago) Jan 12
to Eiffel Users
Cordialement

Jacques Silberstein

In Vision2.

when calling:    

 set_column_alignment (an_alignment: EV_TEXT_ALIGNMENT; a_column: INTEGER_32)
            -- Align the text of column `a_column` to `an_alignment`
            -- The first column must stay as left aligned as MSDN
            -- states that the first column can only be set as left aligned
            -- for Win32.
            -- (from EV_MULTI_COLUMN_LIST)
        require -- from  TOOLS_COLLECTION_PRIMITIVE
            True
        require -- from EV_MULTI_COLUMN_LIST
            not_destroyed: not is_destroyed
            a_column_within_range: a_column > 1 and a_column <= column_count
            alignment_not_void: an_alignment /= Void
        do
            implementation.set_column_alignment (an_alignment, a_column)
        ensure -- from EV_MULTI_COLUMN_LIST
            column_alignment_assigned: column_alignment (a_column).is_equal (an_alignment)
        end


I get the message:

call Stack

a_column_within_range: PRECONDITION_VIOLATION raised


Without assertion check, over GTK the right alignment work properly. 

Conceptualy, it is mot unsfull to build a complexe multi-layer in order to be independant if the platform dependent layer.

Then to solutions:

1) a_column_within_range: a_column >= 1 and a_column <= column_count

and, at msw implementation the request on a right aligment has no effect.

2)low_column_idx: (platform = windows implies a_column > 1  

low_column_idx: (platform /= windows implies a_column >= 1  

The second solution seem a litle bid ugly but...

Capture d’écran du 2025-12-26 15-38-52.png

Liberty Lover

unread,
Jan 12, 2026, 11:55:41 AM (8 days ago) Jan 12
to eiffel...@googlegroups.com
  Jacques,

  Your analysis is correct, and your screenshot confirms it perfectly. The watch panel shows that a_column >= 1 and a_column <= column_count evaluates to True - that's the precondition that should be there.

  Your Solution 1 is the right approach from a Design by Contract perspective:


  a_column_within_range: a_column >= 1 and a_column <= column_count

  The Win32 limitation (first column always left-aligned) should be hidden in the implementation, not exposed in the contract. A "command with no visible effect" is not an error - if you ask to align column 1 on Windows, the request is valid; it simply has no effect due to the underlying platform.

  This preserves EiffelVision2's purpose: platform-independent GUI programming. Code that works on GTK should not crash on Windows because of a platform quirk baked into a precondition.

  Solution 2 (platform-specific preconditions) breaks the abstraction - it forces every caller to know about Win32 ListView internals, which defeats the point of the abstraction layer.

  Recommendation: Report this to ISE as a library issue. The fix is straightforward:
  1. Relax the precondition to a_column >= 1
  2. Have the Win32 implementation silently ignore column 1 alignment requests

  Workaround until fixed:
  if a_column > 1 then
      my_list.set_column_alignment (an_alignment, a_column)
  end

  Best,
  Larry

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/eiffel-users/c6b2ae3f-2871-41b3-ad64-62606acbaa8c%40abstraction.ch.

Ulrich Windl

unread,
Jan 13, 2026, 4:43:03 AM (7 days ago) Jan 13
to eiffel...@googlegroups.com
Hi!

Just wondering: Should the Windows mis-feature be mapped in the postcondition instead? Like "ensure column_1_is_left_aligned:"

Ulrich

12.01.2026 17:55:26 Liberty Lover <rix....@gmail.com>:
>> To view this discussion visit https://groups.google.com/d/msgid/eiffel-users/c6b2ae3f-2871-41b3-ad64-62606acbaa8c%40abstraction.ch[https://groups.google.com/d/msgid/eiffel-users/c6b2ae3f-2871-41b3-ad64-62606acbaa8c%40abstraction.ch?utm_medium=email&utm_source=footer].
>
> --
> You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/eiffel-users/CA%2B3qnjep8bBRW77vKELR5LTOwgoWL3HEkP46JM1vjS5e9P9AnA%40mail.gmail.com[https://groups.google.com/d/msgid/eiffel-users/CA%2B3qnjep8bBRW77vKELR5LTOwgoWL3HEkP46JM1vjS5e9P9AnA%40mail.gmail.com?utm_medium=email&utm_source=footer].
Reply all
Reply to author
Forward
0 new messages