Skip to main content

LogosValue

Enum LogosValue 

Source
pub enum LogosValue {
Show 18 variants Int(i64), BigInt(Arc<BigInt>), Rational(Arc<Rational>), Float(f64), Decimal(Arc<Decimal>), Bool(bool), Text(Arc<str>), Nothing, List(Arc<Vec<LogosValue>>), Tuple(Arc<Vec<LogosValue>>), Algebraic(Arc<Algebraic>), ExactReal(Arc<ExactReal>), Hyperreal(Arc<HyperValue>), Hypernatural(Arc<NaturalValue>), Ordinal(Arc<Ordinal>), Depends(Arc<DependsValue<LogosValue>>), Converging(Arc<Converging<LogosValue>>), Other(Arc<dyn OtherValue>),
}
Expand description

A value of a compiled program where the exact extension reaches. See the module documentation.

Variants§

§

Int(i64)

§

BigInt(Arc<BigInt>)

An integer outside i64; never one that fits.

§

Rational(Arc<Rational>)

A rational that is not whole.

§

Float(f64)

§

Decimal(Arc<Decimal>)

§

Bool(bool)

§

Text(Arc<str>)

§

Nothing

§

List(Arc<Vec<LogosValue>>)

§

Tuple(Arc<Vec<LogosValue>>)

§

Algebraic(Arc<Algebraic>)

§

ExactReal(Arc<ExactReal>)

§

Hyperreal(Arc<HyperValue>)

§

Hypernatural(Arc<NaturalValue>)

§

Ordinal(Arc<Ordinal>)

§

Depends(Arc<DependsValue<LogosValue>>)

§

Converging(Arc<Converging<LogosValue>>)

§

Other(Arc<dyn OtherValue>)

A value of a kind the exact types do not mix with — a date, a span of time, a moment — held as its own compiled value, which prints, compares and combines as the interpreter’s does.

Implementations§

Source§

impl LogosValue

Source

pub fn from_bigint(b: BigInt) -> LogosValue

An integer in its smallest form.

Source

pub fn from_rational(r: Rational) -> LogosValue

A rational in its smallest form: an integer when it is whole.

Source

pub fn text(t: &str) -> LogosValue

Text.

Source

pub fn list(items: Vec<LogosValue>) -> LogosValue

A list.

Source

pub fn other(v: impl OtherValue) -> LogosValue

A value of a kind outside the exact tower.

Source

pub fn other_as<T: OtherValue>(&self) -> Option<&T>

The compiled value of a kind outside the tower this holds, when it holds one of that kind.

Source

pub fn infinitesimal( name: &str, modulus: i64, allowed: &[i64], ) -> Result<LogosValue, String>

The program’s infinitesimal named name, its reciprocal’s residues modulo modulus limited to allowed.

Source

pub fn type_name(&self) -> &str

The value’s type as the language names it.

Source

pub fn display_string(&self) -> String

How the value prints.

Source

pub fn decided_truth(&self) -> Result<bool, String>

The truth a condition reads: a residue-dependent answer, or a provisional one no proof settled, is refused with the sentence every tier gives.

Source

pub fn add(&self, o: &LogosValue) -> Result<LogosValue, String>

a + b.

Source

pub fn sub(&self, o: &LogosValue) -> Result<LogosValue, String>

a − b.

Source

pub fn mul(&self, o: &LogosValue) -> Result<LogosValue, String>

a × b.

Source

pub fn div(&self, o: &LogosValue) -> Result<LogosValue, String>

The polymorphic /: two integers truncate, a rational divides exactly, a float divides as a float, the exact types divide in their field.

Source

pub fn exact_div(&self, o: &LogosValue) -> Result<LogosValue, String>

/ in an exact context: every integer and rational divides exactly; a float defers to /.

Source

pub fn floor_div(&self, o: &LogosValue) -> Result<LogosValue, String>

Floor division.

Source

pub fn rem(&self, o: &LogosValue) -> Result<LogosValue, String>

The remainder of two integers, its sign the dividend’s.

Source

pub fn pow(&self, o: &LogosValue) -> Result<LogosValue, String>

base ^ exponent.

Source

pub fn relation(&self, rel: Rel, o: &LogosValue) -> Result<LogosValue, String>

a rel b: a Bool, or a residue-dependent one where the answer depends on ⌈1/dt⌉.

Source

pub fn values_equal(&self, o: &LogosValue) -> bool

The language’s equality: exact across numeric types, structural on lists and tuples.

Source

pub fn not(&self) -> Result<LogosValue, String>

not v, lifted over residue branches and through provisional values.

Source

pub fn bit_and(&self, o: &LogosValue) -> Result<LogosValue, String>

a & b: bitwise on integers, logical on booleans, and a non-negative big integer under a low mask 2^k - 1 leaves its low k bits.

Source

pub fn bit_or(&self, o: &LogosValue) -> Result<LogosValue, String>

a | b.

Source

pub fn bit_xor(&self, o: &LogosValue) -> Result<LogosValue, String>

a ^ b.

Source

pub fn shl(&self, o: &LogosValue) -> Result<LogosValue, String>

a << b, the count taken modulo the width.

Source

pub fn shr(&self, o: &LogosValue) -> Result<LogosValue, String>

a >> b, the count taken modulo the width.

Source

pub fn approx_eq(&self, o: &LogosValue) -> Result<LogosValue, String>

a is approximately b, on the two values as floats.

Source

pub fn seq_concat(&self, o: &LogosValue) -> Result<LogosValue, String>

a followed by b: the items of two sequences, in order.

Source

pub fn abs(&self) -> Result<LogosValue, String>

The builtin abs: exact on integers (promoting |i64::MIN|), rationals and decimals.

Source

pub fn sqrt(&self) -> Result<LogosValue, String>

The builtin sqrt, a float.

Source

pub fn min(&self, o: &LogosValue) -> Result<LogosValue, String>

The builtin min.

Source

pub fn max(&self, o: &LogosValue) -> Result<LogosValue, String>

The builtin max.

Source

pub fn power(&self, o: &LogosValue) -> Result<LogosValue, String>

The builtin pow: an integer power is exact, a negative one a float.

Source

pub fn length_of(&self) -> Result<i64, String>

length of self: a list’s or a tuple’s item count, a text’s byte count.

Source

pub fn contains_value(&self, value: &LogosValue) -> Result<bool, String>

self contains value: an equal item of a list, a substring of a text.

Source

pub fn items(&self) -> Result<Vec<LogosValue>, String>

The values a Repeat over self binds, taken once before the loop runs: a list’s items, a text’s characters.

Source

pub fn push_value(&mut self, value: LogosValue) -> Result<(), String>

Push value to self.

Source

pub fn set_item( &mut self, index: &LogosValue, value: LogosValue, ) -> Result<(), String>

Set item index of self to value.

Source

pub fn pop_value(&mut self) -> Result<LogosValue, String>

Pop from self: the last item, or nothing from an empty list.

Source

pub fn item(&self, index: &LogosValue) -> Result<LogosValue, String>

item index of self: the 1-based item of a list or a tuple, the character of a text.

Source

pub fn slice( &self, start: &LogosValue, end: &LogosValue, ) -> Result<LogosValue, String>

items start through end of self: the 1-based, inclusive run of a list’s items (crate::logos_slice_range); one that reaches outside the list is empty.

Source

pub fn integer_at(&self, past_word: &str, fraction: &str) -> Result<i64, String>

The machine integer this is where the language takes one: refused with past_word for an integer past i64, with fraction for a rational that is not whole, and by its type for any other value.

Source

pub fn into_real(self) -> f64

The real an operator over a real answers.

Source

pub fn floor(&self) -> Result<LogosValue, String>

The language’s floor.

Source

pub fn ceil(&self) -> Result<LogosValue, String>

The language’s ceil.

Source

pub fn round(&self) -> Result<LogosValue, String>

The language’s round.

Source§

impl LogosValue

Source

pub fn defined_real( kind: &str, base: i64, name: &str, f: impl Fn(i64) -> LogosValue + Send + Sync + 'static, ) -> LogosValue

The real number f defines by its digits in base or its approximations (kind, as logicaffeine_base::exact_real::Definition::named reads it), name being how the program spells f.

Source

pub fn define_real( kind: &str, base: i64, name: &str, f: impl Fn(i64) -> Result<LogosValue, String> + Send + Sync + 'static, ) -> Result<LogosValue, String>

LogosValue::defined_real for a function that may refuse an answer, refused itself when kind and base name no definition.

Source

pub fn sendable(&self) -> Result<(), String>

Ok when the value may cross to a task, Err with the interpreter’s sentence when it holds a real number a function of the program defines, which stays with the program.

Trait Implementations§

Source§

impl Clone for LogosValue

Source§

fn clone(&self) -> LogosValue

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LogosValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LogosValue

An unset slot of an exact type, as the interpreter starts one: nothing.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for LogosValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&str> for LogosValue

Source§

fn from(t: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for LogosValue

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl From<LogosDate> for LogosValue

Source§

fn from(d: LogosDate) -> Self

Converts to this type from the input type.
Source§

impl From<LogosDecimal> for LogosValue

Source§

fn from(d: LogosDecimal) -> Self

Converts to this type from the input type.
Source§

impl From<LogosInt> for LogosValue

Source§

fn from(n: LogosInt) -> Self

Converts to this type from the input type.
Source§

impl From<LogosMoment> for LogosValue

Source§

fn from(m: LogosMoment) -> Self

Converts to this type from the input type.
Source§

impl From<LogosRational> for LogosValue

Source§

fn from(r: LogosRational) -> Self

Converts to this type from the input type.
Source§

impl<T: Clone + Into<LogosValue>> From<LogosSeq<T>> for LogosValue

Source§

fn from(items: LogosSeq<T>) -> Self

Converts to this type from the input type.
Source§

impl From<LogosSpan> for LogosValue

Source§

fn from(s: LogosSpan) -> Self

Converts to this type from the input type.
Source§

impl From<LogosTime> for LogosValue

Source§

fn from(t: LogosTime) -> Self

Converts to this type from the input type.
Source§

impl From<String> for LogosValue

Source§

fn from(t: String) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<LogosValue>> From<Vec<T>> for LogosValue

Source§

fn from(items: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for LogosValue

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for LogosValue

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for LogosValue

Source§

fn from(n: i128) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for LogosValue

Source§

fn from(n: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for LogosValue

Source§

fn from(n: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for LogosValue

Source§

fn from(n: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for LogosValue

Source§

fn from(n: i8) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for LogosValue

Source§

fn from(n: u128) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for LogosValue

Source§

fn from(n: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for LogosValue

Source§

fn from(n: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for LogosValue

Source§

fn from(n: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for LogosValue

Source§

fn from(n: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for LogosValue

Source§

fn from(n: usize) -> Self

Converts to this type from the input type.
Source§

impl LogosIndex<LogosValue> for LogosValue

Source§

type Output = LogosValue

The type of element returned by indexing.
Source§

fn logos_get(&self, index: LogosValue) -> LogosValue

Get the element at the given index.
Source§

impl LogosIndex<i64> for LogosValue

Source§

type Output = LogosValue

The type of element returned by indexing.
Source§

fn logos_get(&self, index: i64) -> LogosValue

Get the element at the given index.
Source§

impl PartialEq for LogosValue

Source§

fn eq(&self, o: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TowerValue for LogosValue

Source§

fn exact(&self) -> Option<ExactRef<'_, Self>>

The value as one of the exact types, or None for any other value.
Source§

fn standard_rational(&self) -> Option<Rational>

An integer, rational, decimal or finite float as the rational it denotes exactly.
Source§

fn integer(&self) -> Option<BigInt>

An Int or big integer.
Source§

fn exact_rational(&self) -> Option<Rational>

An integer or a rational: a number held exactly, never a float or a decimal.
Source§

fn is_standard_number(&self) -> bool

An integer, rational, decimal or float: its own standard part.
Source§

fn text(&self) -> Option<&str>

A Text value’s characters.
Source§

fn type_name(&self) -> String

The value’s type as the language names it.
Source§

fn display_string(&self) -> String

How the value prints.
Source§

fn values_equal(&self, other: &Self) -> bool

The language’s equality on two values.
Source§

fn is_nothing(&self) -> bool

Whether the value is nothing.
Source§

fn from_rational(r: Rational) -> Self

A rational in its smallest form: an Int when it fits, a big integer, else a rational.
Source§

fn from_bigint(b: BigInt) -> Self

An integer in its smallest form.
Source§

fn boolean(b: bool) -> Self

Source§

fn nothing() -> Self

Source§

fn algebraic(a: Algebraic) -> Self

Source§

fn exact_real(x: ExactReal) -> Self

Source§

fn hyper(h: HyperValue) -> Self

Source§

fn natural(n: NaturalValue) -> Self

Source§

fn ordinal(o: Ordinal) -> Self

Source§

fn depends(d: DependsValue<Self>) -> Self

Source§

fn converging(c: Converging<Self>) -> Self

Source§

impl Truthy for LogosValue

Source§

fn truthy(&self) -> bool

Source§

impl ValueAlgebra for LogosValue

Source§

fn add(a: Self, b: Self) -> Result<Self, String>

Source§

fn subtract(a: Self, b: Self) -> Result<Self, String>

Source§

fn multiply(a: Self, b: Self) -> Result<Self, String>

Source§

fn exact_divide(a: Self, b: Self) -> Result<Self, String>

/ in an exact context: field division, integers included.
Source§

fn modulo(a: Self, b: Self) -> Result<Self, String>

The language’s %.
Source§

fn power(a: Self, b: Self) -> Result<Self, String>

The language’s **.
Source§

fn holds(rel: Rel, a: &Self, b: &Self) -> Result<bool, String>

Whether a rel b holds, decided: an answer that depends on the residue, or a provisional one, is the refusal of the branch.
Source§

fn floor(v: Self) -> Result<Self, String>

The language’s floor.
Source§

fn ceil(v: Self) -> Result<Self, String>

The language’s ceiling.
Source§

fn list(values: Vec<Self>) -> Self

Source§

fn shape(&self) -> Shape<Self>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.