io.put_string_32 ("[
         Hello!
         ¡Hola!
         Bonjour!
         こんにちは!
         Здравствуйте!
         Γειά σου!
      ]")

Unicode output in console

feature -- Access

  ...

invariant

  all_items_valid: ∀ x: items ¦ x.is_valid
  at_least_one_marked: ∃ x: items ¦ x.is_marked

end

Assertions: class invariants with symbolic notation

values := << 1, 2, 4, 8 >>

    --    Sum of (index * values [index]).
across
    values as i 
from 
    sum := 0 
loop
    sum := sum + i.cursor_index * i.item
end

Sum using across loop

rating := locale.plural_translation_in_context
      ("$1 star", "$1 stars", "example.context", n)
...

rating: READABLE_STRING_32
      -- Translated message.

locale: I18N_LOCALE
      -- Currently selected locale with translations.
   do ... end

Internationalization

class DINING_PHILOSOPHER
...
feature -- Basic operations

   eat (left, right: separate FORK)
         -- Race-free access to the forks `left` and `right`.
      do
          left.use
          right.use
      end

end

Concurrency with SCOOP

feature -- Access
    balance: INTEGER -- Current balance in dollars.
feature -- Element change
    withdraw (amount: INTEGER) -- Remove `amount` dollars.
        require
            positive: amount > 0
            not_too_big: amount <= balance
        do
            balance := balance - amount
        ensure
            increased: balance = old balance - amount
        end

Bank account example

run
        -- Execute tasks from `pool`.
    do
        from until
            not attached retrieved_task (pool) as task
        loop
            separate task as t do
                t.call
            end
        end
    end

Running a pool of tasks

class REFEREE:
    race_start.publish (create {DATE_TIME}.make_now_utc)
class RACE_CONTROL:
    race_start: EVENT_TYPE [DATE_TIME]
class SPRINTER:
    race_start.subscribe (agent run_from_now)
    run_from_now (t: DATE_TIME)
            -- Record `t` as starting time and get running.
        do
            start_time := t
            run
        end

Event-based programming with agents

Recent posts

  • News

  • Forum

  • Facebook

Community

This site is powered by Eiffel.

Built with the Eiffel ROC-CMS based on EiffelWeb.