MoonBit月兔编程语言 现代编程思想 第十一课 案例:语法解析器与Tagless FinalOption[(Expression, List[Token])] { ... } 12. 13. // 返回函数代表的解析器 14. Parser(expression) 15. } 21 语法树之外:Tagless Final 计算表达式,除了⽣成为抽象语法树再解析,我们还可以有其他的选择 我们通过�⾏为�来进⾏抽象 1. trait Expr { 2. number(Int) -> Self 3. op_mul(Self, Self) -> Self 6. op_div(Self, Self) -> Self 7. } 接⼝的不同实现即是对⾏为的不同语义 22 语法树之外:Tagless Final 我们利⽤⾏为的抽象定义解析器 1. fn recursive_parser[E : Expr]() -> Parser[E] { 2. let number : Parser[E] recursive_parser().parse(token_list)? 18. Some(expr, rest_string, rest_token) 19. } 23 语法树之外:Tagless Final 我们可以提供不同的实现,获得不同的诠释 1. enum Expression { ... } derive(Debug) // 语法树实现 2. type BoxedInt Int derive(Debug)0 码力 | 25 页 | 400.29 KB | 1 年前3
云原生中的数据科学KubeConAsia2018Final0 码力 | 47 页 | 14.91 MB | 1 年前3
Java 应用与开发 - 面向对象编程进阶大纲 多态性 方法重载 关键字 static 关键字 final Java 应用与开发 面向对象编程进阶 PART2 王晓东 wangxiaodong@ouc.edu.cn 中国海洋大学 September 30, 2018 大纲 多态性 方法重载 关键字 static 关键字 final 学习目标 1. 理解多态和虚方法调用的概念,掌握其用法 2. 掌握方法重载的方法 3. 掌握 了解设计模式,掌握单例设计模式 5. 掌握 final 关键字的概念和使用方法 大纲 多态性 方法重载 关键字 static 关键字 final 大纲 多态性 方法重载 关键字 static 关键字 final 大纲 多态性 方法重载 关键字 static 关键字 final 接��� 多态性 方法重载 关键字 static 关键字 final 大纲 多态性 方法重载 关键字 static static 关键字 final 什么是多态? 在 Java 中,子类的对象可以替代父类的对象使用称为多态。 O Java 引用变量与所引用对象间的类型匹配关系 ▶ 一个对象只能属于一种确定的数据类型,该类型自对象创建 直至销毁不能改变。 ▶ 一个引用类型变量可能引用(指向)多种不同类型的对象 ——既可以引用其声明类型的对象,也可以引用其声明类型 的子类的对象。 1 Person p =0 码力 | 49 页 | 659.74 KB | 1 年前3
《Java 应用与开发》课程讲义 - 王晓东. . . 54 5.3.4 Singleton 设计模式 . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 5.4 关键字 final . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 5.5 课后习题 . . . . . . 单精度后加 f 或 F,双精度后加 d 或 D 可省略。 逻辑型常量 true 或者 false。 字符型常量 单引号。 字符串常量 双引号。 示例代码:常量的声明 1 final int MAX = 10; 2 final float PI =3.14f; 变量 变量的属性包括变量名、类型、值和地址。Java 语言程序中可以随时定义变量,不 必集中在执行语句之前。 示例代码:变量声明、初始化和赋值 assert boolean break byte case catch char class continue default do double else enum extends false final finally float for if implements import instanceof int interface long native new null package private0 码力 | 330 页 | 6.54 MB | 1 年前3
2022年美团技术年货 合辑口供策略类调用进行注册。同时使用饿汉式单例模式去优化策略类的设计: // 策略上下文,用于管理策略的注册和获取 class StrategyContext { private static final MapregisterMap = new HashMap<>(); // 注册策略 public static void registerStrategy(String } } // 单例外卖策略 class Waimai extends AbstractStrategy implements Strategy { private static final Waimai instance = new Waimai(); private WaimaiService waimaiService; private Waimai() { } } // 单例酒旅策略 class Hotel extends AbstractStrategy implements Strategy { private static final Hotel instance = new Hotel(); private HotelService hotelService; private Hotel() { 0 码力 | 1356 页 | 45.90 MB | 1 年前3
Blender v4.1 Manualredesign of the internal window manager and event/tool/data handling system, and new Python API. The final version of this project was Blender 2.59 in August 2011. Blender 2.6x to 2.7x – Improvements & Stabilizing Tells the render engine to use the node tree when computing the material color or rendering the final image, or not. If not, the tree is ignored. For materials, this is mostly a legacy option, because through search. This can be useful for node asset authors to hide their internal sub-groups from the final user. Interface When a node group is created, new Group Input and Group Output nodes are generated0 码力 | 6263 页 | 303.71 MB | 1 年前3
Java 应用与开发 - 线程编程类与后台线程相关的方法 1. 测试当前线程是否为守护线程,如果是则返回 true,否则返 回 false 1 public final boolean isDaemon() 2. 将当前线程标记为守护线程或用户线程,本方法必须在启动 线程前调用 1 public final void setDaemon(Boolean on) 课程配套代码 ± sample.thread.DaemonThreadSample 5,子线程的优先级默认与其父线程相同。可以使用 Thread 类提供的方法获得和设置线程的优先级: ▶ 获取当前线程优先级 1 public final int getPriority(); ▶ 设定当前线程优先级 1 public final void setPriority(int newPriority); 相关静态整型常量: 1 Thread.MIN_PRIORITY = 1 在多线程程序中,如果在一个线程运行的过程中要用到另一个线 程的运行结果,则可进行线程的串型化处理。 Thread 类提供的相关方法: 1 public final void join() 2 public final void join(long millis) 3 public final void join(long millis, int nanos) 课程配套代码 ± sample.thread.ThreadJoinSample0 码力 | 82 页 | 1010.73 KB | 1 年前3
Apache ShardingSphere v5.5.0 documentIf there are multiple ${ expression } or $->{ expression } expressions in a row expression, the final result of the whole expression will be a Cartesian combination based on the result of each sub‐expression data node transactions succeed or not. There is no loss in performance, but strong consistency and final consistency cannot be guaranteed. XA Transaction XA transaction adopts the concepts including AP(application exchange for higher system throughput. ACID‐based strong consistency transactions and BASE‐based final consistency transactions are not a jack of all trades and can fully leverage their advantages in0 码力 | 602 页 | 3.85 MB | 1 年前3
Apache RocketMQ 从入门到实战RemotingC ommand request) throws RemotingCommandException { final RemotingCommand response = RemotingCommand.createResponseCom mand(null); final GetConsumeStatsRequestHeader requestHeader = (GetConsum rocketmq 监控相关)。 BrokerStatsManager#tpsGroupGetNums public double tpsGroupGetNums(final String group, final String topic) { final String statsKey = buildStatsKey(topic, group); // @1 本文来自『中间件兴趣圈』公众号,仅作技术交流,未授权任何商业行为。 sDataInMinute 方法。 StatsItemSet#getStatsDataInMinute public StatsSnapshot getStatsDataInMinute(final String statsKey) { StatsItem statsItem = this.statsItemTable.get(statsKey); if (null != statsItem)0 码力 | 165 页 | 12.53 MB | 1 年前3
JAVA 应用与开发 - 高级类特性29 ���� 接口�定义的����� public static final 的��接口�定义的方 法���� public abstract 的����������部���部 ��� CODE ± 接口示例(未简化) 1 public interface Runner { 2 public static final int id = 1; 3 public abstract void ������������用��������� 抽象类������方法的实现����接口����� public abstract 方法 抽象类�的������为��类���接口�的����� �� public static final 类� 抽象类�����������方法�接口�������� ������方法 ��类��继承��抽象类����类���实现多�接口 15 29 ������� ������������用��������� ������������用��������� 抽象类������方法的实现����接口����� public abstract 方法 抽象类�的������为��类���接口�的����� �� public static final 类� 抽象类�����������方法�接口�������� ������方法 ��类��继承��抽象类����类���实现多�接口 15 29 ������� ������������用���������0 码力 | 61 页 | 677.55 KB | 1 年前3
共 229 条
- 1
- 2
- 3
- 4
- 5
- 6
- 23













