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

Unicode output in console

feature -- Access

  ...

invariant

  all_items_valid: across items as x all x.item.is_valid end
  at_least_one_marked: across items as x some x.item.is_marked end

end

Assertion: class invariants

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

class ACCOUNT
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

    deposit (amount: INTEGER)  -- Add `amount` dollars.
        require
            positive: amount > 0
        do
            balance := balance + amount
        ensure
            increased: balance = old balance + amount
        end

invariant
    no_overdraft: balance >= 0
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

Agent code

Welcome to the community portal for Eiffel,
the programming language
for tackling tomorrow’s problems today.

EiffelStudio 19.05 GPL - win64
Download Now

Recent posts

  • News

  • Forum

  • Facebook

Community

This site is powered by Eiffel.

Built with the Eiffel ROC-CMS based on EiffelWeb.